UIImagePickerController 卸载底层 ViewController 并出现内存警告
在我的 iPhone 应用程序中,我注意到使用 UIImagePickerController 时通常会导致内存警告发生。我读到这并不罕见,而且我知道我的内存占用量非常小。
我的问题是,当 UIImagePickerController 启动并抛出内存警告时,它会卸载呈现它的视图。用户选择视频或图像后,由于视图被重新加载,他们之前输入的数据就会消失。
有什么办法可以防止视图卸载,或者有更好的解决方案吗?我见过类似的问题,但没有好的解决方案。
感谢您的回答。
In my iPhone application, I've noticed that when using the UIImagePickerController it typically causes memory warnings to happen. I've read that this isn't uncommon and I know that my memory footprint is pretty small otherwise.
My problem is that when UIImagePickerController is up and it throws a memory warning, it unloads the view that presented it. After a user selects a video or image, their previously entered data is gone since the view was reloaded.
Is there any way to prevent the view from unloading, or is there a better solution? I've seen similar questions, but no good solutions.
Thanks for your answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阻止视图卸载可能不是一个好主意,因为您正在与收割者玩“小鸡游戏”(即操作系统可能会因行为不当而杀死您的应用程序)。
如果您担心丢失状态信息,您可以将该数据写入应用程序临时目录中的临时文件中的磁盘,并在视图/控制器中设置一个标志“从磁盘重新加载我”。
Preventing the view from unloading is probably not a good idea, since you're playing a game of chicken with the reaper (i.e. the OS could kill your app for misbehaving).
If you're concerned about losing state information, you could write that data to disk in a temporary file in your application's temp directory, and set a flag in the view/controller that says "reload me from disk".