Interface Builder是否使用-init方法来初始化视图控制器? [英] Does Interface Builder use the -init method to initialize view controllers?

查看:90
本文介绍了Interface Builder是否使用-init方法来初始化视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用界面构建器设置标签栏控制器,每个标签栏项目链接到视图控制器(4个选项卡,4个视图控制器)。我想知道Interface Builder是否使用 -init 方法来初始化视图控制器,因为显然这个方法不会被调用:

I have setup tab bar controller using interface builder, and each tab bar item is linked to a view controller (4 tabs, 4 view controllers). I want to know if Interface Builder uses an -init method to initialize the view controller because apparently this method does not get called:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;

...我想做一些初始化。我不能添加到 -viewDidLoad ,因为它是在内存警告的情况下被调用。任何想法?

... and I want to do some initializations. I can't add that to -viewDidLoad since it is recalled in case of memory warning. Any idea?

推荐答案

*(nib | xib)引入:

- (id)initWithCoder:(NSCoder *)inCoder;

所以你可以覆盖或者如果你在 -initWithCoder: / code>被调用不是一个你可以使用的问题:

So you could override that or if doing your setup after -initWithCoder: is called is not a problem you could use:

- (void)awakeFromNib;

这篇关于Interface Builder是否使用-init方法来初始化视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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