内存警告后,关闭模式并从后台返回后,iOS 5 选项卡出现空白屏幕
- 使用 iOS 5 模拟器或设备运行带有选项卡的应用程序
- 调出模式对话框
- 模拟内存警告(对于设备,请转到某些内存密集型应用程序)
- 切换到另一个应用程序(如果您尚未这样做)
- 返回应用程序
- 关闭该对话框
您将看到一个空白屏幕(窗口)。演示此错误/问题的测试项目: http://github.com/chetanpungaliya/iOS-5-测试模式
- Run a app with tabs using iOS 5 simulator or device
- Bring up a modal dialog
- Simulate memory warning (for devices go to some apps that are memory intensive)
- Switch to another app (if you have not done so already)
- Come back to the app
- Dismiss the dialog
You will see a blank screen (the window). Test project to demonstrate this bug / issue: http://github.com/chetanpungaliya/iOS-5-TestModal
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我今天自己也遇到了这个问题,除了这是一个 iOS 5 的错误之外找不到任何解释。经过一番黑客攻击后,我找到了一个解决方法。在关闭模态视图控制器之前,请将 tabBarController.selectedIndex 更改为不同的视图控制器索引,然后再返回。
您可以在 https://github.com/xjones/iOS- 的项目克隆中看到这一点5-测试模式。我还将此作为拉取请求提交给您。
编辑:添加了 openradar 报告
有人也在 openradar 上发布了此内容: http://openradar.appspot.com/10529236
I ran into this myself today and can't find any explanation other than it's an iOS 5 bug. After a bit of hacking, I found a workaround. Before you dismiss the modal view controller, change
tabBarController.selectedIndex
to a different view controller index and then back again.You can see this in a clone of your project at https://github.com/xjones/iOS-5-TestModal. I also submitted this to you as a pull request.
EDIT: added openradar report
Someone has also posted this on openradar: http://openradar.appspot.com/10529236
我也有同样的问题并解决了它。问题是我们通过 xib 连接的插座在 viewDidUnload 方法中设置为 nil。当发生内存警告时,会在当前不可见的所有视图上调用此方法。当我们回到这些视图时,它们的 viewDidLoad 方法会再次被调用。解决此问题的唯一方法是将 setNil 方法从 viewDIdUnload 删除到 dealloc 方法,一切都会正常工作。
I too had the same issue and fixed it. The problem is that the outlets that we connect via xib are set to nil in viewDidUnload method. This method is called on all views that are not currently visible, when memory warning occurs. When we come back to those views, their viewDidLoad method is called again. The only way to fix this is to remove setNil methods from viewDIdUnload to dealloc method and everything will work fine.