[英]AwakeFromNib has nil outlets
In my RootViewController, I have IBOutlets. 在我的RootViewController中,我有IBOutlets。 I can access them by
viewWillAppear
but they are all nil in awakeFromNib()
我可以通过
viewWillAppear
访问它们,但是在awakeFromNib()
它们都为零
I am calling super.awakeFromNib()
我正在打电话给
super.awakeFromNib()
Why are they all nil? 他们为什么都没有? Doesn't the Apple document guarantee that all the outlets from my view controller are initialized when
awakeFromNib
is called? Apple文档不保证在调用
awakeFromNib
时初始化了我的视图控制器中的所有插座吗?
https://developer.apple.com/documentation/objectivec/nsobject/1402907-awakefromnib https://developer.apple.com/documentation/objectivec/nsobject/1402907-awakefromnib
Quote from the apple dev docs: 引用苹果开发人员的文档:
When an object receives an
awakeFromNib
message, it is guaranteed to have all its outlet and action connections already established.当一个对象收到
awakeFromNib
消息时,可以保证它的所有出口和动作连接已经建立。
For a UIViewController
method awakeFromNib
is called when the controller is "awake" from Nib file. 对于
UIViewController
方法,当控制器从Nib文件“唤醒”时,将调用awakeFromNib
。 You should use viewDidLoad
is you want to interact with outlets. 如果要与插座交互,则应使用
viewDidLoad
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.