didReceiveMemoryWarning 应用程序崩溃
我正在尝试编写我的 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];
}
非常感谢任何帮助或指导。谢谢
I am trying to write my didReceiveMemoryWarning method.
Should I simply set my IBOutlets to nil like in my ViewDidUnload?
I am simulating a memory warning on the iPhone Simulator, but the second time I run it, the app crashes.
- (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];
}
Any help or direction is very much appreciated. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 UIViewController 的视图不可见,它将卸载其视图以响应内存警告。由于您没有覆盖
-didReceiveMemoryWarning
的行为,因此您不需要在该方法中执行任何操作。只需让视图控制器正常运行即可。因此,您的应用程序崩溃是由于其他一些问题造成的,而您没有提供足够的信息来确定可能是什么问题。
A UIViewController will unload its view in response to a memory warning if its view is not visible. Since you're not overriding the behavior of
-didReceiveMemoryWarning
you shouldn't need to do anything in that method. Just allow the view controller to behave normally.Your app's crash is therefore due to some other problem and you have not provided enough information to determine what that might be.