简体   繁体   中英

AwakeFromNib has nil outlets

In my RootViewController, I have IBOutlets. I can access them by viewWillAppear but they are all nil in awakeFromNib()

I am calling 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?

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.

For a UIViewController method awakeFromNib is called when the controller is "awake" from Nib file. You should use viewDidLoad is you want to interact with outlets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM