开发者

How is an IBOutlet UIViewController constructed?

开发者 https://www.devze.com 2023-03-02 20:28 出处:网络
I\'m extending Apple\'s template for lazy table image loading. I would like the following code to run when RootViewController is constructed.

I'm extending Apple's template for lazy table image loading. I would like the following code to run when RootViewController is constructed.

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
object: nil];

The problem is I don't how how RootViewController is constructed. I tried the following two methods, but they were never executed. I put NSLog in those methods and they were never printed out.

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

I opened MainWindow.xib and noticed that it loads RootViewController as an IBOutlet in the UIApplicati开发者_开发问答onDelegate. Now, RootViewController is a subclass of UIViewController. So the question boils down to "how is an IBOutlet UIViewController constructed?"


You can executed the code you need to execute in the awakeFromNib method, this is called by the decoder once the outlet is created.

0

精彩评论

暂无评论...
验证码 换一张
取 消