开发者

When is an IBOutlet UIViewController inited, if set as a property? How to optimize IBOutlet UIViewControllers' loading?

I have my main app view controller (File's Owner), its First Responder, View, and 3 other UIViewControllers in the same nib file. Every one of the 3 UIViewControllers is referenced on the main UIViewController as an IBOutlet.

My quest开发者_Python百科ion is, when does the main UIViewController init those 3 UIViewControllers, in its life cycle (my guess is sometime before calling viewDidLoad) and should I worry with optimizing how and when they are loaded. The reasoning is obviously that if the app loads the main view controller and then right away starts loading the other view controllers, the user might have to wait for everything to get loaded first. But if I could still have the IBOutlets synthesized, but have the option to decide when those view controllers (and their views) are loaded, then this would definitely be an improvement.


The UIViewController doesn’t initialize the outlets, that’s done by the nib loading code before awakeFromNib and viewDidLoad. Anything that is in one nib file gets loaded, instantiated and intialized at the same time. So as long as your views are in the same nib there is no way to load them on demand. You should put the other views in different nib files and load them when they are needed. Putting everything in one nib is not a good idea.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜