当 iPhone 从睡眠状态重新打开且应用程序仍处于打开状态时释放
在某些情况下,当我的应用程序从睡眠状态重新打开且应用程序仍处于打开状态时会崩溃。如果当 iPhone 进入睡眠状态时 UITableViews 打开,就会发生这种情况;该表是从正在解析的 XML 中填充的。我明白为什么它会崩溃;在我的 viewDidUnload 方法中,我正在释放填充表格的数组。我不确定如何处理这个问题;是的,我可以简单地不在 viewDidUnload 中释放它,但是如果您返回主菜单,它永远不会留下内存。
任何帮助将不胜感激!
There are a few instances where my app crashes when turned back on from sleep and the app is still open. It happens if a UITableViews is open when the iPhone is put into sleep; the table is being filled from an XML being parsed. I understand why it is crashing; in my viewDidUnload method I am releasing the array that is filling the table. How to handle this I am not sure; yes I could simply not release it in viewDidUnload, but then it would never leave memory if you returned to the main menu.
Any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
viewDidUnload 方法根本不是释放数据的正确位置。我引用苹果的文档,它比我能更好地描述它:
ViewDidUnload 仅用于释放视图相关对象。视图控制器可以释放其视图,因为它未显示,但该控制器的实例仍然存在,您的模型也存在。
The method viewDidUnload is not the right place to release your data if at all. I quote Apple's documentation, which desribes it better than I could:
ViewDidUnload is used only to release view related objects. A view controller can release its view because its not shown, still your instance of that controller exists and so does your model.