diff --git a/jiaModuleDemo/BaseModule/JiaCore/JiaAppDelegate.m b/jiaModuleDemo/BaseModule/JiaCore/JiaAppDelegate.m index 1c5e510..b923ad9 100644 --- a/jiaModuleDemo/BaseModule/JiaCore/JiaAppDelegate.m +++ b/jiaModuleDemo/BaseModule/JiaCore/JiaAppDelegate.m @@ -11,9 +11,6 @@ @implementation JiaAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - //网络状态通知监听 - [GLobalRealReachability startNotifier]; //是否开始日志记录功能 if(JiaCoreConfigManagerInstance.isRecordlogger) diff --git a/jiaModuleDemo/BaseModule/JiaCore/JiaBaseViewController.m b/jiaModuleDemo/BaseModule/JiaCore/JiaBaseViewController.m index fe9676d..2c1f98b 100644 --- a/jiaModuleDemo/BaseModule/JiaCore/JiaBaseViewController.m +++ b/jiaModuleDemo/BaseModule/JiaCore/JiaBaseViewController.m @@ -66,10 +66,13 @@ -(void)viewDidLoad [self configRightBaritemWithImage]; } + //添加一个通知监听网络状态切换 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkChanged:) name:kRealReachabilityChangedNotification object:nil]; + [GLobalRealReachability startNotifier]; + ReachabilityStatus status = [GLobalRealReachability currentReachabilityStatus]; //当无网络时 每进一个页面都进行提示 if (status == RealStatusNotReachable) @@ -110,6 +113,7 @@ -(void)viewDidAppear:(BOOL)animated -(void)dealloc { + [GLobalRealReachability stopNotifier]; //移除通知 [[NSNotificationCenter defaultCenter]removeObserver:self]; } @@ -270,8 +274,7 @@ - (void)networkChanged:(NSNotification *)notification { RealReachability *reachability = (RealReachability *)notification.object; ReachabilityStatus status = [reachability currentReachabilityStatus]; - ReachabilityStatus previousStatus = [reachability previousReachabilityStatus]; - NSLog(@"networkChanged, currentStatus:%@, previousStatus:%@", @(status), @(previousStatus)); + if (status == RealStatusNotReachable) {