UIImagePickerController 卸载底层 ViewController 并出现内存警告

发布于 2024-10-06 04:45:18 字数 261 浏览 0 评论 0原文

在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余厌 2024-10-13 04:45:18

阻止视图卸载可能不是一个好主意,因为您正在与收割者玩“小鸡游戏”(即操作系统可能会因行为不当而杀死您的应用程序)。

如果您担心丢失状态信息,您可以将该数据写入应用程序临时目录中的临时文件中的磁盘,并在视图/控制器中设置一个标志“从磁盘重新加载我”。

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".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文