获取网络状态,区分2G3G4GWIFI等,非reachability
来源:互联网 发布:时时彩统计软件 编辑:程序博客网 时间:2024/04/29 07:19
原文:http://www.cocoachina.com/bbs/read.php?tid=227757
+(NSString *)getNetWorkStates{
UIApplication *app = [UIApplication sharedApplication];NSArray *children = [[[app valueForKeyPath:@"statusBar"]valueForKeyPath:@"foregroundView"]subviews];
NSString *state = [[NSString alloc]init];
int netType = 0;
//获取到网络返回码
for (id child in children) {
if ([child isKindOfClass:NSClassFromString(@"UIStatusBarDataNetworkItemView")]) {
//获取到状态栏
netType = [[child valueForKeyPath:@"dataNetworkType"]intValue];
switch (netType) {
case 0:
state = @"无网络";
//无网模式
break;
case 1:
state = @"2G";
break;
case 2:
state = @"3G";
break;
case 3:
state = @"4G";
break;
case 5:
{
state = @"WIFI";
}
break;
default:
break;
}
}
}
//根据状态选择
return state;
}
根据状态栏获取网络状态,可以区分2G、3G、4G、WIFI,系统的方法,比较快捷。稍微蛋疼的是万一连接的WIFI没有联网的话···你懂得
0 0
- 获取网络状态,区分2G3G4GWIFI等,非reachability
- iOS 获取网络状态,区分2G3G4GWIFI等,非reachability
- iOS 获取网络状态,区分2G3G4GWIFI等,非reachability
- 获取网络状态,区分2G3G4GWIFI等,非reachability
- 获取网络状态,区分2G3G4GWIFI等,非reachability
- 获取网络状态,区分2G3G4GWIFI等,非reachability
- iOS获取网络状态,区分2G、3G、4G、WIFI,非reachability
- iOS获取设备网络状态,2G,3G,4G,wifi,非Reachability
- 使用 Reachability 获取网络状态
- 使用 Reachability 获取网络状态
- iOS - 检测网络状态: Reachability和非Reachability
- Reachability 检查网络状态
- Reachability检测网络状态
- 网络状态检测Reachability
- 网络状态监测Reachability
- Reachability类检测网络状态
- Reachability类检测网络状态
- Reachability 类检测网络状态
- struct2 返回结果类型
- 【C/C++】浅谈sizeof
- Mysql:Can't connect to MySQL server on ‘localhost' (10061)
- java Socket网络通信简介
- 使用automatorX测试app页面响应时间
- 获取网络状态,区分2G3G4GWIFI等,非reachability
- Latex论文排版技巧再总结
- Android静态/动态注册广播的区别
- redhat7.0/centos7.0 yum安装提示Exiting on user cancel的解决方法
- Android通过广播接收者调用服务内方法
- 数据库原理(十一)-- 数据库恢复
- 运算符在变量名
- python模块及包的导入
- 修改Odoo 8版权信息