IOS window.rootViewController 切换原rootViewController无法释放(问题解决)
ios 解决 无法 切换 window 释放 问题
2023-09-27 14:21:17 时间
先说一下问题吧,今天遇到了一个奇怪的问题。一个界面通过消息通知刷新数据,断点跑了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 。
什么鬼东西,这也都可以????
在这里做一个记录吧,希望给大家一个提示。
相关文章
- iOS解决Launch Screen.storyboard启动画面黑屏
- iOS解决WKWebView页面内无法跳转
- iOS exit(),abort(),assert()函数区别
- iOS 9音频应用播放音频之第一个ios9音频实例
- Xamarin iOS教程之视图显示图像
- 《iOS组件与框架——iOS SDK高级特性剖析》——第8章,第8.5节解决冲突
- IOS开发中UIBarButtonItem上按钮切换或隐藏实现案例
- iOS Core ML与Vision初识
- A blog about Core Animation and other iOS graphics framework
- ios面试心得
- iOS绘图UIBezierPath 和 Core Graphics框架
- 『零行代码』解决键盘遮挡问题(iOS)
- 谈谈iOS中粘性动画以及果冻效果的实现
- iOS 集合的深复制与浅复制
- iOS开发网络篇—文件的上传
- javascript js date ios手机浏览器出现 NAN的问题解决方法
- 解决uniapp的websocket连接在web和安卓正常,iOS连接不上的问题
- IOS云打包修改权限提示语解决IOS提交审核相册等隐私描述语导致审核失败,提示“没有阐明相机在适用的用途字符串中的使用”的问题
- iOS xmpp的使用
- iOS ERROR: unable to get the receiver data from the DB 解决方式
- 升级iOS 10之后 正确的解锁方式是怎样的?
- iOS-UITextView设置行间距,内容颜色(变相设置类似UITextField的placeholder)
- iOS - UITableView reloadData滚动到顶部无效问题解决
- iOS - 利用 iTunes 接口检查 App 版本更新
- IOS开发之Bug--使用xib的自动布局和代码中修改遇到的bug