判断Iphone,Ipad当前网络状态
2012-03-16 11:11
183 查看
1、到苹果管网下载Reachability的Demo,https://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
然后把:Reachability.h 和 Reachability.m 添加到工程中
2、使用如下方法就能判断当前是否联网:
bool CCNetworkConfig::isNetworkAvailable()
{
Reachability *r = [ReachabilityreachabilityWithHostName:@"www.apple.com"];
switch ([rcurrentReachabilityStatus]) {
caseReachableViaWWAN: // 使用3G网络
printf("current network 3g/gprs\n");
return true;
caseReachableViaWiFi: // 使用WiFi网络
printf("current network wifi\n");
return true;
caseNotReachable: // 没有网络连接
default:
break;
}
printf("current network none\n");
return false;
}
然后把:Reachability.h 和 Reachability.m 添加到工程中
2、使用如下方法就能判断当前是否联网:
bool CCNetworkConfig::isNetworkAvailable()
{
Reachability *r = [ReachabilityreachabilityWithHostName:@"www.apple.com"];
switch ([rcurrentReachabilityStatus]) {
caseReachableViaWWAN: // 使用3G网络
printf("current network 3g/gprs\n");
return true;
caseReachableViaWiFi: // 使用WiFi网络
printf("current network wifi\n");
return true;
caseNotReachable: // 没有网络连接
default:
break;
}
printf("current network none\n");
return false;
}
相关文章推荐
- 判断Iphone,Ipad当前网络状态
- 判断Iphone,Ipad当前网络状态
- iPhone判断当前网络连接状态
- iPhone判断当前网络连接状态
- iphone 判断当前网络状态
- iphone 判断当前网络状态
- iOS-iPhone开发之判断当前的网络状态
- iphone 判断当前网络状态
- iPhone开发之判断当前的网络状态
- Android 判断当前网络状态是不是WiFi
- Android之判断当前网络状态
- IOS中如何判断当前网络状态
- Android检测网络状态,判断当前网络是否可用
- 【ios开发】如何判断当前网络连接状态(网络是否正常)
- Android中getSystemService介绍,获取系统的运行状态,判断当前网络状态
- Android检测网络状态,判断当前网络是否可用
- Android学习--判断当前设备的网络状态
- Android判断当前的网络连接状态
- iPhone开发 判断当前的网络是3g还是wifi
- Android检测网络状态,判断当前网络是否可用