先說一下問題吧,今天遇到了一個奇怪的問題。一個界面通過消息通知刷新數據,斷點跑了2次,感覺很奇怪。通過和公司小伙伴溝通發現是由於退出登錄后再登錄進去后發現此問題。我首先想到的就是此功能界面沒有釋放,但是查看界面處理沒有特殊操作。里面想到就是因為切換rootViewController的時候原rootViewController沒有釋放掉。查看了原 rootViewController界面A,在發現界面A並沒有其他原因導致其有可能不被釋放。
立即想到了自己做的UIViewController 的擴展處理中有問題,把擴展去掉后釋放正常。
先附上我切換rootViewController 的代碼如下(代碼中忽略我的其他操作)
+(void)setRootViewViewController:(UIViewController *)controller{ UIWindow * window = [UIApplication sharedApplication].delegate.window; //清空root if (window.rootViewController){ window.rootViewController = nil; } UINavigationController * navTabBar = [[UINavigationController alloc] initWithRootViewController:controller]; window.rootViewController = navTabBar; system_titleStatusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height; system_titleViewHeight = navTabBar.navigationBar.frame.size.height + system_titleStatusBarHeight; controller.automaticallyAdjustsScrollViewInsets = NO; if ([controller isKindOfClass:[UITabBarController class]]) { system_tabbarHeight = ((UITabBarController *)controller).tabBar.frame.size.height; } [JLBRouter manager].navigationVC = navTabBar; }
在分析擴展代碼中並沒有發現導致沒有釋放的原因是我調用了
self.navigationController.presentationController 。
什么鬼東西,這也都可以????
在這里做一個記錄吧,希望給大家一個提示。