【问题标题】:didReceiveMemoryWarning app crashingdidReceiveMemoryWarning 应用程序崩溃
【发布时间】:2011-05-18 20:02:09
【问题描述】:

我正在尝试编写我的 didReceiveMemoryWarning 方法。 我应该像在 ViewDidUnload 中那样简单地将 IBOutlets 设置为 nil 吗?

我在 iPhone 模拟器上模拟内存警告,但我第二次运行它时,应用程序崩溃了。

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

- (void)viewDidUnload {

self.repCount=nil;
self.weight=nil;
self.repUp=nil;
self.repDown=nil;
self.weightUp=nil;
self.weightDown=nil;
self.next=nil;
self.weightLabel=nil;
self.titleLabel=nil;
self.repLabel=nil;

[super viewDidUnload];

}

非常感谢任何帮助或指导。谢谢

【问题讨论】:

  • 你的意思是第二次模拟内存警告,对吧?
  • 是的,我第二次模拟内存警告应用程序崩溃。
  • 错误说明了什么?你能提供一些细节吗?我没有看到这里的代码有问题。

标签: iphone cocoa-touch memory-management memory-leaks didreceivememorywarning


【解决方案1】:

如果视图不可见,UIViewController 将卸载其视图以响应内存警告。由于您没有覆盖 -didReceiveMemoryWarning 的行为,因此您不需要在该方法中执行任何操作。让视图控制器正常运行即可。

因此,您的应用程序崩溃是由于其他一些问题,而您没有提供足够的信息来确定可能是什么原因。

【讨论】:

  • 感谢也解决了崩溃问题。是否需要覆盖 didReceiveMemoryWarning?我很难弄清楚我应该发布什么......
  • 不,覆盖 didReceiveMemoryWarning 是可选的。但如果你这样做了,你就必须打电话给 super。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-05-13
  • 2011-03-31
  • 1970-01-01
  • 2011-01-19
  • 1970-01-01
  • 2013-02-03
  • 2011-01-01
相关资源
最近更新 更多