自己整理的IOS网络检测和版本检测代码
来源:互联网 发布:安卓apk软件 编辑:程序博客网 时间:2024/05/06 18:56
要导入的头文件
#import "Reachability.h"
网络检测代码段
BOOL isExistenceNetwork;
Reachability *r = [ReachabilityreachabilityWithHostName:@"www.apple.com"];
switch ([rcurrentReachabilityStatus]) {
caseNotReachable:
isExistenceNetwork=FALSE;
break;
caseReachableViaWWAN:
isExistenceNetwork=TRUE;
break;
caseReachableViaWiFi:
isExistenceNetwork=TRUE;
break;
}
if (!isExistenceNetwork) {
UIAlertView *myalert = [[UIAlertViewalloc] initWithTitle:@"网络连接不佳" message:@"请检查网络连接,并重启程序" delegate:self cancelButtonTitle:@"确认"otherButtonTitles:nil,nil];
myalert.delegate =self;
myalert.tag =2;
[myalertshow];
[myalertrelease];
return YES;
}
版本检测代码段
if(AppVersion < version){
NSString *prompt = [NSStringstringWithFormat:@"IBMUnixWorld已更新到%1.1f版本",version];
UIAlertView *av=[[[UIAlertViewalloc] initWithTitle:@"版本更新" message:prompt delegate:selfcancelButtonTitle:@"否"otherButtonTitles:@"是",nil] autorelease];
av.tag =1;
[avshow];
}
//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;
[[UIApplicationsharedApplication] openURL:[NSURLURLWithString:appURL]];
}
}elseif(alertView.tag ==2){
exit(1);
}
}
- 自己整理的IOS网络检测和版本检测代码
- 自己整理的IOS网络检测和版本检测代码
- ios检测版本更新代码
- ios 机型检测和网络检测
- iOS版本检测代码(更新版本)
- 检测IOS的版本信息
- ios--代码检测sdk版本ios6/ios7
- ios网络状态的检测
- Android 检测代码规范和检测bug的工具汇总整理
- ios-版本升级检测
- iOS 检测版本更新
- iOS 检测版本更新
- IOS检测版本更新
- iOS 检测版本
- iOS检测版本更新
- iOS 检测版本更新
- iOS 检测版本更新
- IOS 版本更新检测
- oracle创建用户、授予权限及删除用户
- java 中 print类似的用法 android density dip与px
- c,c++中的日期,时间 time_t和 struct tm转换
- MyEclipse中直接查看class文件的方法
- JAVAWEB常见缺包异常
- 自己整理的IOS网络检测和版本检测代码
- Java乔晓松-简单标签3
- Extjs,如何使treenode双击不选中前面的checkbox
- 主题:Mybatis3.0查询,保存,更新,删除数据。
- 用VA快速添加注释+快捷键
- ORACLE中一个字符占多少字节?
- UVA 11374 - Airport Express
- Android的animation的四种动画
- Windows下安装Apache2,PHP,SSL