viewDidUnload与viewDidDisappear [英] viewDidUnload versus viewDidDisappear

查看:128
本文介绍了viewDidUnload与viewDidDisappear的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白何时应该在 viewDidUnload viewDidDisappear 中实现某些内容。这两者有什么区别?

I don't understand when I should implement something in viewDidUnload versus viewDidDisappear. What's the difference between the two?

例如,我想在视图控制器发送 NSNotificaton 从视图层次结构中删除。在这两种方法之间,我发布通知的位置是否重要?

For instance, I'd like to send an NSNotificaton when the view controller is removed from the view hierarchy. Between these two methods, does it matter where I post that notification from?

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html

推荐答案

这是参考apple的文档: -

This is with reference to apple's documentation:-

viewDidUnload: -

viewDidUnload:-

当出现内存不足的情况并且不需要当前视图控制器的视图时,系统可能会选择从内存中删除这些视图。在视图控制器的视图发布后调用此方法,并且您有机会执行任何最终清理。如果视图控制器存储对视图或其子视图的单独引用,则应使用此方法释放这些引用。您还可以使用此方法删除对您为支持视图而创建的任何对象的引用,但现在视图已不再需要。

When a low-memory condition occurs and the current view controller’s views are not needed, the system may opt to remove those views from memory. This method is called after the view controller’s view has been released and is your chance to perform any final cleanup. If your view controller stores separate references to the view or its subviews, you should use this method to release those references. You can also use this method to remove references to any objects that you created to support the view but that are no longer needed now that the view is gone.

viewDidDisappear: -

viewDidDisappear:-

通知视图控制器其视图已从每次视图消失或移动到其他视图的视图层次结构中删除。

Notifies the view controller that its view was removed from a view hierarchy that is everytime view dissapears or move to other view.

这篇关于viewDidUnload与viewDidDisappear的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆