zoukankan      html  css  js  c++  java
  • 判断联网wifi

    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;

                }

            }

        }

     

       

  • 相关阅读:
    RabbitMQ 部署记录
    Linux下安装db2
    CentOS7 安装 Redis 并设置开机启动
    Firewalld 使用指南
    centos7 redis安装教程
    Centos7下杀毒软件clamav的安装和使用
    centos7 zookeeper集群搭建
    centos开机执行JAR Shell脚本
    centos7 防火墙常用设置
    centos7 Systemd 指令详解
  • 原文地址:https://www.cnblogs.com/jinchengvs/p/5067194.html
Copyright © 2011-2022 走看看