zoukankan      html  css  js  c++  java
  • AFN的实时网络监控 但是block连续调用了两次

      [[AFNetworkReachabilityManager sharedManager] startMonitoring];

        [[AFNetworkReachabilityManager sharedManager ] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {

            switch (status) {

                case -1:

                    NSLog(@"未知网络");

                    break;

                case 0:

                    NSLog(@"网络不可达");

                    break;

                case 1:

                    NSLog(@"移动网络");

                    break;

                case 2:

                    NSLog(@"wifi网络");

                    break;

                default:

                    break;

            }

            if(status ==AFNetworkReachabilityStatusReachableViaWWAN || status == AFNetworkReachabilityStatusReachableViaWiFi)

            {

                NSLog(@"有网");

            }else

            {

                UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"网络失去连接" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];

                alert.delegate = self;

                [alert show];

            }

        }];

    由于连续调用了两次 导致界面逻辑出现一个没有显示出来就跳转到下一个的bug  

    建议只有一份代码 代码里不要写与业务相关的代码   以后用afn的网络状态判断网络情况
    挥毫泼墨,书写人生篇章
  • 相关阅读:
    加密模块
    Flask_Blueprint(蓝图)
    Python中__get__ ,__getattr__ ,__getattribute__用法与区别?
    为什么要使用数据库连接池?以及用法(DBUtils)
    Flask_配置文件
    CRM知识点汇总(未完💩💩💩💩💩)
    popUp
    Django_调查问卷
    Django_form
    Numpy
  • 原文地址:https://www.cnblogs.com/Jusive/p/7048597.html
Copyright © 2011-2022 走看看