我已经非常习惯使用viewDidLoad方法执行我想要在视图开头执行的操作,但是阅读Apple的一个教程,他们在awakeFromNib方法中为类设置了数据控制器,并且在awakeFromNib中没有做任何事情.我交换了它,它似乎在我的应用程序中工作相同,但我不确定它是否更好在awakeFromNib或viewDidLoad中.
我什么时候应该使用其中一个?
awakeFromNib is called when the associated nib file with a class is loaded . Any class that can own a nib can use it. viewDidLoad is used only by view controllers. It is usually called when loading from nib as well but it can also be called by a view created in memory (very rare circumstance.). If you are using controllers, then I would suggest you to use viewDidLoad
For more Refer this Answer
| 归档时间: |
|
| 查看次数: |
6556 次 |
| 最近记录: |