判断Iphone,Ipad当前网络状态
2012-02-06 17:04
218 查看
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判断当前网络连接状态
- iOS-iPhone开发之判断当前的网络状态
- iPhone判断当前网络连接状态
- iphone 判断当前网络状态
- iphone 判断当前网络状态
- iphone判断当前网络连接类型WIF、WWAN、2G和3G
- iPhone开发 判断当前的网络是3g还是wifi
- iPhone开发 判断当前的网络是3g还是wifi
- iPhone开发 判断当前的网络
- iPhone开发 判断当前的网络是3g还是wifi
- iphone开发使用Reachability判断网络状态
- iphone判断当前网络连接类型
- Android检测网络状态,判断当前网络是否可用
- Android 判断当前的网络状态
- Android 判断当前网络连接状态
- 判断当前的网络状态