你的位置:首页 > 软件开发 > 操作系统 > 判断联网wifi

判断联网wifi

发布时间:2016-03-03 18:00:07
UIApplication *app = [UIApplication sharedApplication];NSArray *children = [[[app valueForKeyPath:@"statusBar"]valueForKeyPath:@&q ...

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;

            }

        }

    }

 

   


原标题:判断联网wifi

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录