出现内存警告后如何保留导航历史记录?

发布于 2024-12-02 00:55:23 字数 404 浏览 0 评论 0原文

在我的应用程序中,我有一个视图控制器,它抛出一个UIImagePickerController,产生内存警告。经过多次研究,我没有找到防止此警告的解决方案。

问题是:当我的应用程序收到内存警告时,导航历史记录似乎丢失了,当用户按下后退按钮时,我的应用程序启动第一个控制器。 (就像当我的应用程序启动时)

内存警告之后我如何保留导航历史记录? 或者更好的是我如何使用UIImagePickerController删除这个内存警告? (我尝试了在 stackoverflow.com 和 google.com 中找到的很多解决方案)

对我来说另一个解决方案是防止内存警告释放控制器的所有数据。

In my app I have a viewcontroller which throwing an UIImagePickerController that produces a memory warning. After many research I don't have found a solution to prevent this warning.

The problem is: When my app receives a memory warning the history of the navigation seems to be lost and when the user presses the back button, my app starts the first controller. (like when my app starts)

How i can keep the history of my navigation after a memory warning?
Or better how i can remove this memory warning with the UIImagePickerController? (I tried a lot of solutions found in stackoverflow.com and google.com)

An other solution for me is to prevent the memory warning to release all data of my controller.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

漫雪独思 2024-12-09 00:55:23

如果不查看代码,我无法帮助您解决内存警告,但 TTNavigator 似乎会将您发送回堆栈中的第一个视图控制器,因为它无法保留其他视图控制器。

你继承自TTViewController吗?如果没有,你应该尝试一下。其次,如果从 TTViewController 继承后仍然遇到问题,请考虑在视图控制器中实现以下方法:

- (BOOL)persistView:(NSMutableDictionary*)state {
  // Save important state information into the state dictionary
  // provided to you and return yes to tell TTNavigator to persist
  // this view controller
  return YES;
}

- (void)restoreView:(NSDictionary*)state {
  // Read the values you saved in state and restore your view
  // controller's state
}

这些方法在 Three20UI 项目的 UIViewControllerAdditions.h 中定义。希望有帮助。

I can't help you with the memory warning without looking at the code but it seems like TTNavigator sends you back to the first view controller in the stack because it can't persist the others.

Are you inheriting from TTViewController? If not you should try that. Secondly if you're still having problems after inheriting from TTViewController look into implementing the following methods in your view controller:

- (BOOL)persistView:(NSMutableDictionary*)state {
  // Save important state information into the state dictionary
  // provided to you and return yes to tell TTNavigator to persist
  // this view controller
  return YES;
}

- (void)restoreView:(NSDictionary*)state {
  // Read the values you saved in state and restore your view
  // controller's state
}

Those methods are defined in UIViewControllerAdditions.h in the Three20UI project. Hope that helps.

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