在一个方法中调用viewdidload是个好主意吗? [英] is it a good idea to call viewdidload in a method?

查看:88
本文介绍了在一个方法中调用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
}

这篇关于在一个方法中调用viewdidload是个好主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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