Where is the best place to run initialization code for a UITabBarController?

Posted by bobobobo on Stack Overflow See other posts from Stack Overflow or by bobobobo
Published on 2010-04-28T20:52:31Z Indexed on 2010/04/28 20:57 UTC
Read the original article Hit count: 244

I have a UITabBarController in my application. I have to perform some customization to the NIB file using code the first time a view embedded in that UITabBarController gets loaded.

When applicationDidFinishLaunching occurs, the UITabBarController's views apparently are not loaded -- if I try to modify the view controllers inside a tab bar that the tab bar is to load in applicationDidFinishLaunching, then those changes are ignored. I'm assuming this is because the tab bar didn't finish loading yet.

So, I need a good place to put code that will run immediately after a tabbar is fully ready -- i.e. after it has loaded all the views from their respective nib files. I'm finding the only place I can do this is to track the first time viewDidAppear on each individual view controller. Note I can't use viewWillAppear because I need the value of tabBarController.selectedIndex to be accurate, and it is only actually updated after viewDidAppear gets fired, not when viewWillAppear gets fired.

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.2

Related posts about uitabbarcontroller