自己整理的IOS网络检测和版本检测代码
2013-11-09 16:29
459 查看
网络检测代码段
BOOL isExistenceNetwork;
Reachability *r = [Reachability reachabilityWithHostName:@"www.apple.com"];
switch ([r currentReachabilityStatus]) {
case NotReachable:
isExistenceNetwork=FALSE;
break;
case ReachableViaWWAN:
isExistenceNetwork=TRUE;
break;
case ReachableViaWiFi:
isExistenceNetwork=TRUE;
break;
}
if (!isExistenceNetwork) {
UIAlertView *myalert = [[UIAlertView alloc] initWithTitle:@"网络连接不佳" message:@"请检查网络连接,并重启程序" delegate:self cancelButtonTitle:@"确认" otherButtonTitles:nil,nil];
myalert.delegate = self;
myalert.tag = 2;
[myalert show];
[myalert release];
return YES;
}
版本检测代码段
if(AppVersion < version){
NSString *prompt = [NSString stringWithFormat:@"IBMUnixWorld已更新到%1.1f版本",version];
UIAlertView *av=[[[UIAlertView alloc] initWithTitle:@"版本更新" message:promptdelegate:self cancelButtonTitle:@"否" otherButtonTitles:@"是", nil] autorelease];
av.tag = 1;
[av show];
}
//alertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
//NSLog(@"clickedButtonAtIndex %d",buttonIndex);
if(alertView.tag == 1){
if(buttonIndex == 1){
NSLog(@"appStoreLinkURL %@",appStoreLinkURL);
NSString *appURL = appStoreLinkURL;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appURL]];
}
}else if(alertView.tag == 2){
exit(1);
}
}
BOOL isExistenceNetwork;
Reachability *r = [Reachability reachabilityWithHostName:@"www.apple.com"];
switch ([r currentReachabilityStatus]) {
case NotReachable:
isExistenceNetwork=FALSE;
break;
case ReachableViaWWAN:
isExistenceNetwork=TRUE;
break;
case ReachableViaWiFi:
isExistenceNetwork=TRUE;
break;
}
if (!isExistenceNetwork) {
UIAlertView *myalert = [[UIAlertView alloc] initWithTitle:@"网络连接不佳" message:@"请检查网络连接,并重启程序" delegate:self cancelButtonTitle:@"确认" otherButtonTitles:nil,nil];
myalert.delegate = self;
myalert.tag = 2;
[myalert show];
[myalert release];
return YES;
}
版本检测代码段
if(AppVersion < version){
NSString *prompt = [NSString stringWithFormat:@"IBMUnixWorld已更新到%1.1f版本",version];
UIAlertView *av=[[[UIAlertView alloc] initWithTitle:@"版本更新" message:promptdelegate:self cancelButtonTitle:@"否" otherButtonTitles:@"是", nil] autorelease];
av.tag = 1;
[av show];
}
//alertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
//NSLog(@"clickedButtonAtIndex %d",buttonIndex);
if(alertView.tag == 1){
if(buttonIndex == 1){
NSLog(@"appStoreLinkURL %@",appStoreLinkURL);
NSString *appURL = appStoreLinkURL;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appURL]];
}
}else if(alertView.tag == 2){
exit(1);
}
}
相关文章推荐
- 自己整理的IOS网络检测和版本检测代码
- iOS 检测网络 无须代码便可以设置
- IOS上传照片(自己的代码整理了一下)
- ios--代码检测sdk版本ios6/ios7
- IOS上传照片(自己的代码整理了一下)
- IOS上传照片(自己的代码整理了一下)
- ios检测版本更新代码
- ios 检测网络 无须代码就可以设置
- 自己整理的iOS代码编写规范
- ios检测网络变化
- iOS通过iTunes search检测版本更新,并提示用户更新!
- iOS 检测版本更新
- iOS开发--统计自己的工程有多少行代码
- iOS开发之检测网络连接状态
- wp7检测网络是否可用以及网络开启简单代码段
- iOS开发检测AppStore版本更新
- iOS 检测版本更新(02)
- 深度学习 13. 能力提升, 一步一步的介绍如何自己构建网络和训练,利用MatConvNet(二),思路整理
- javascript 检测浏览器类型和版本的代码