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的网络状态判断网络情况
    挥毫泼墨,书写人生篇章
  • 相关阅读:
    删除git上已经提交的文件
    spark安装
    Ganglia+nagios 监控hadoop资源与报警
    自定义标签库开发与el表达式
    JavaBean与MVC
    Jsp-查漏补缺
    HttpSession
    Cookie
    HttpServleRequest
    Servlet学习-查漏补缺
  • 原文地址:https://www.cnblogs.com/Jusive/p/7048597.html
Copyright © 2011-2022 走看看