在一个方法中调用viewdidload是个好主意吗?
我只是好奇的天气,这是一个好主意,调用viewdidload一个像ibaction或类似的东西。
I was just curious weather it is a good idea to call viewdidload a method like in an ibaction or something of that kind.
感谢,
TC
thanks, TC
br>
UIViewController类参考 p>
Check:
UIViewController Class Reference
viewDidLoad
控制器已将其关联的
视图加载到内存中。此方法是
调用,不管视图
是存储在nib文件中还是在loadView
方法中以编程方式创建
。这种方法最常见的是
用于对从nib文件加载的
视图执行额外的
初始化步骤。
This method is called after the view controller has loaded its associated views into memory. This method is called regardless of whether the views were stored in a nib file or created programmatically in the loadView method. This method is most commonly used to perform additional initialization steps on views that are loaded from nib files.
自动触发 viewDidLoad
方法。
通常不需要触发 viewDidLoad
自己。
如果您需要在加载和点击按钮后运行特定代码,请执行以下操作:
The viewDidLoad
method is automatically triggered.
Generally there is no need to trigger viewDidLoad
yourself.
If you need to run specific code both after loading and button-click, do this:
- (void)viewDidLoad {
[self specificFunction];
}
- (IBAction)theButton:(id)sender {
[self specificFunction];
}
- (void)specificFunction {
// This code wil run after the view has been loaded
// and when the user clicks the button
}