当前位置: 编程技术>移动开发
本页文章导读:
▪WARNING: Application does not specify an API level requirement WARNING: Application does not specify an API level requirement!
修改AndroidManifest.xml,添加sdkVersion例如:[2011-06-14 10:45:47 - m8book_播放页面菜单] WARNING: Application does not specify an API level requirement![2011-06-14 10:45:47 .........
▪ 代码自定义UIScrollView兑现 代码自定义UIScrollView实现
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle.........
▪ 运用服务器信任证书,访问https服务器 使用服务器信任证书,访问https服务器
参考ASIHHPRequest开源项目中的ClientCertificateTests.m源码。链接:https://github.com/pokeb/asi-http-request/blob/master/Classes/Tests/ClientCertificateTests.m以及:http://developer.........
[1]WARNING: Application does not specify an API level requirement
来源: 互联网 发布时间: 2014-02-18
WARNING: Application does not specify an API level requirement!
修改AndroidManifest.xml,添加sdkVersion
例如:
[2011-06-14 10:45:47 - m8book_播放页面菜单] WARNING: Application does not specify an API level requirement!
[2011-06-14 10:45:47 - m8book_播放页面菜单] Device API version is 3 (Android 1.5)
网上一查是由于没有指定users sdk的缘故,修改AndroidManifest.xml文件.
加入:
<uses-sdk android:minSdkVersion="3"></uses-sdk>
加在<manifest> </manifest> 之间.
[2011-06-14 10:45:47 - m8book_播放页面菜单] WARNING: Application does not specify an API level requirement!
[2011-06-14 10:45:47 - m8book_播放页面菜单] Device API version is 8 (Android 2.2)
加入:
<uses-sdk android:minSdkVersion="8"></uses-sdk>
加在<manifest> </manifest> 之间.
修改AndroidManifest.xml,添加sdkVersion
例如:
[2011-06-14 10:45:47 - m8book_播放页面菜单] WARNING: Application does not specify an API level requirement!
[2011-06-14 10:45:47 - m8book_播放页面菜单] Device API version is 3 (Android 1.5)
网上一查是由于没有指定users sdk的缘故,修改AndroidManifest.xml文件.
加入:
<uses-sdk android:minSdkVersion="3"></uses-sdk>
加在<manifest> </manifest> 之间.
[2011-06-14 10:45:47 - m8book_播放页面菜单] WARNING: Application does not specify an API level requirement!
[2011-06-14 10:45:47 - m8book_播放页面菜单] Device API version is 8 (Android 2.2)
加入:
<uses-sdk android:minSdkVersion="8"></uses-sdk>
加在<manifest> </manifest> 之间.
[2] 代码自定义UIScrollView兑现
来源: 互联网 发布时间: 2014-02-18
代码自定义UIScrollView实现
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
self.title = @"主流公司指数";
mainView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
mainView.delegate = self;
[self.view addSubview:mainView];
UIBarButtonItem *reloadItem = [[UIBarButtonItem alloc] initWithTitle:@"重新加载" style:UIBarButtonItemStylePlain target:self action:@selector(reloadItem_click)];
self.navigationItem.rightBarButtonItem = reloadItem;
/*mainView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, 400)];
mainView.directionalLockEnabled = YES;
mainView.pagingEnabled = YES;
mainView.backgroundColor = [UIColor blueColor];
mainView.showsVerticalScrollIndicator = NO;
mainView.showsHorizontalScrollIndicator = NO;
mainView.delegate = self;
CGSize newSize = CGSizeMake(self.view.frame.size.width * 2, self.view.frame.size.height);
[mainView setContentSize:newSize];
[self.view addSubview:mainView];
pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0.0, 401, self.view.frame.size.width, 80)];
pageControl.hidesForSinglePage = YES;
pageControl.userInteractionEnabled = NO;
pageControl.backgroundColor = [UIColor redColor];
[self.view addSubview:pageControl];
page1=[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height)];
page1.backgroundColor=[UIColor redColor];
[mainView addSubview:page1];
page2=[[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width, 0.0, self.view.frame.size.width, self.view.frame.size.height)];
page2.backgroundColor=[UIColor blueColor];
[mainView addSubview:page2]; //[mainView setBackgroundColor:[UIColor redColor]];
*/
}
return self;
}
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
/*BfViewController *bf = [[BfViewController alloc]init];
[self.view addSubview:bf.view];
[bf setTopicText:@"test"];
[bf setMarkText:@"mark"];
*/
/*[super viewDidLoad];
waitView = [[UIWaitingView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:waitView];
[self.view bringSubviewToFront:waitView];
[waitView starActivityLoading];
[waitView setLoadingLabel:@"正在加载数据..."];
*/
//[bf release];
//[bf2 release];
}
- (void)viewDidAppear:(BOOL)animated{
NSLog(@"CompanyController.viewDidAppear");
[super viewDidAppear:animated];
if(companyList==nil){
[[WaitDialog sharedWaitDialog] setLoadingLabel:@"链接网络中.."];
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(fetchData) userInfo:nil repeats:NO];
}
}
-(void)fetchData{
[self removeAllView];
companyList = [JSONParser loadData:@"http://3g.wapzq.com/odds/json/company.jsp" isAllValues:NO valueForKey:@"list"];
//NSLog(@"companyList:%@",arr);
//[waitView endActivityLoading];
//[waitView removeFromSuperview];
//[[WaitDialog sharedWaitDialog]endShowLoading];
[[WaitDialog sharedWaitDialog]setLoadingLabel:@"正在构造界面..."];
[self makeView];
}
-(void)removeAllView{
for(UIView *subView in [mainView subviews]){
[subView removeFromSuperview];
}
}
-(void)makeView{
[[WaitDialog sharedWaitDialog]endShowLoading];
if(companyList==nil||[companyList count]==0){
UILabel *nullData = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, self.view.frame.size.width-20, 40)];
nullData.text = @"暂时没有数据";
nullData.backgroundColor = [UIColor clearColor];
nullData.font = [UIFont systemFontOfSize:20];
[mainView addSubview:nullData];
}else{
int count = [companyList count];
int i = 0;
int x = 10;
int y = 10;
int width = self.view.frame.size.width / 2 - 40;
int height = 30;
int contentHeight = (height+y*2)*count/2;
CGSize newSize = CGSizeMake(self.view.frame.size.width,contentHeight);
[mainView setContentSize:newSize];
for(i = 0; i < count/2; i++){
NSArray *company = [companyList objectAtIndex:i];
// NSLog(@"index %d has %@.",i, [companyList objectAtIndex:i]);
//NSLog(@"company.id:%@,name:%@",[company valueForKey:@"cid"],[company valueForKey:@"name"]);
UIButton *btn = [[UIButton buttonWithType:UIButtonTypeRoundedRect]retain];
btn.frame = CGRectMake(x, y, width, height);
btn.backgroundColor = [UIColor clearColor];
//UIButton*btn=[[UIButton alloc]initWithFrame:CGRectMake(x, y, width, height)];
//btn.backgroundColor = [UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1];
//[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btn setTitle:[company valueForKey:@"name"] forState:UIControlStateNormal];
//btn.titleLabel.font = [UIFont systemFontOfSize:19];
[btn addTarget:self action:@selector(selectCompany:) forControlEvents:UIControlEventTouchUpInside];
[mainView addSubview:btn];
[btn release];
y+=height+10;
}
x = self.view.frame.size.width /2 +10;
y = 10;
for(i;i<count;i++){
NSArray *company = [companyList objectAtIndex:i];
UIButton *btn = [[UIButton buttonWithType:UIButtonTypeRoundedRect]retain];
btn.frame = CGRectMake(x, y, width, height);
//[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btn setTitle:[company valueForKey:@"name"] forState:UIControlStateNormal];
//btn.titleLabel.font = [UIFont systemFontOfSize:19];
[btn addTarget:self action:@selector(selectCompany:) forControlEvents:UIControlEventTouchUpInside];
[mainView addSubview:btn];
[btn release];
y+=height+10;
}
}
}
[3] 运用服务器信任证书,访问https服务器
来源: 互联网 发布时间: 2014-02-18
使用服务器信任证书,访问https服务器
参考ASIHHPRequest开源项目中的ClientCertificateTests.m源码。
链接:https://github.com/pokeb/asi-http-request/blob/master/Classes/Tests/ClientCertificateTests.m
以及:http://developer.apple.com/library/mac/#documentation/Security/Conceptual/CertKeyTrustProgGuide/iPhone_Tasks/iPhone_Tasks.html
项目中,要添加Security.framework。
参考ASIHHPRequest开源项目中的ClientCertificateTests.m源码。
链接:https://github.com/pokeb/asi-http-request/blob/master/Classes/Tests/ClientCertificateTests.m
以及:http://developer.apple.com/library/mac/#documentation/Security/Conceptual/CertKeyTrustProgGuide/iPhone_Tasks/iPhone_Tasks.html
+ (void)testClientCertificate {
NSURL *httpsUrl = [NSURL URLWithString:@"https://xxxxxx.xx.xx"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:httpsUrl];
SecIdentityRef identity = NULL;
SecTrustRef trust = NULL;
//绑定证书,证书放在Resources文件夹中
NSData *PKCS12Data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"client" ofType:@"p12"]];
[HttpsTestViewController extractIdentity:&identity andTrust:&trust fromPKCS12Data:PKCS12Data];
request = [ASIHTTPRequest requestWithURL:httpsUrl];
[request setClientCertificateIdentity:identity];
[request setValidatesSecureCertificate:NO];
[request startSynchronous];
error = [request error];
if (!error) {
NSString *response = [request responseString];
NSLog(@"response is : %@",response);
} else {
NSLog(@"Failed to save to data store: %@", [error localizedDescription]);
NSLog(@"%@",[error userInfo]);
}
}
+ (BOOL)extractIdentity:(SecIdentityRef *)outIdentity andTrust:(SecTrustRef*)outTrust fromPKCS12Data:(NSData *)inPKCS12Data {
OSStatus securityError = errSecSuccess;
CFStringRef password = CFSTR("xxxxxx"); //证书密码
const void *keys[] = { kSecImportExportPassphrase };
const void *values[] = { password };
CFDictionaryRef optionsDictionary = CFDictionaryCreate(NULL, keys,values, 1,NULL, NULL);
CFArrayRef items = CFArrayCreate(NULL, 0, 0, NULL);
//securityError = SecPKCS12Import((CFDataRef)inPKCS12Data,(CFDictionaryRef)optionsDictionary,&items);
securityError = SecPKCS12Import((CFDataRef)inPKCS12Data,optionsDictionary,&items);
if (securityError == 0) {
CFDictionaryRef myIdentityAndTrust = CFArrayGetValueAtIndex (items, 0);
const void *tempIdentity = NULL;
tempIdentity = CFDictionaryGetValue (myIdentityAndTrust, kSecImportItemIdentity);
*outIdentity = (SecIdentityRef)tempIdentity;
const void *tempTrust = NULL;
tempTrust = CFDictionaryGetValue (myIdentityAndTrust, kSecImportItemTrust);
*outTrust = (SecTrustRef)tempTrust;
} else {
NSLog(@"Failed with error code %d",(int)securityError);
return NO;
}
return YES;
}
项目中,要添加Security.framework。
最新技术文章: