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

问题描述

当我覆盖方法 viewDidLoad 时,我应该先调用它,然后编写我的代码吗?还是相反?

When I override the method viewDidLoad, should I call it first and then write my code or is it the other way around?

推荐答案

调用 super 的实现.方法是先进先出:

Call super's implementation. The approach is FIFO:

- (void)viewDidLoad
{
 [super viewDidLoad];
 // code...
}

- (void)viewDidUnload
{
 // code...
 [super viewDidUnload];
}

要获得更多的见解,请参阅有关View Controller的Apple文档: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/BasicViewControllers/BasicViewControllers.html

To gain a little more insight, look at Apple's documentation on View Controller: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/BasicViewControllers/BasicViewControllers.html

也可以看到类似的(重复?)问题和答案:`[super viewDidLoad]`约定

Also see this similar (dup?) question and answer: `[super viewDidLoad]` convention

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

10-19 06:05