iOS---检测网络状态

来源:互联网 发布:东华软件股票怎么样 编辑:程序博客网 时间:2024/05/16 14:46

将Reachability.h 和 Reachability.m 加自己的项目中,并引用 SystemConfiguration.framework,就可以使用了。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{if (([Reachability reachabilityForInternetConnection].currentReachabilityStatus==NotReachable)||([Reachability reachabilityForLocalWiFi].currentReachabilityStatus==NotReachable))    {        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"警告" message:@"您的设备暂时没有可用的网络!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];        [alert show];        [alert release];    } } 

  



原创粉丝点击