Something very strange is happening to me. I've been double and triple checking myself. I'm using a UITabBarController, and initializing it with 4 different view controllers. However, for some reason, when the application starts, only the first tab bar image is displayed. It's only when I touch the blank part of the tab bar开发者_如何学运维 - then the underlying image suddenly appears.
I suspect it's a bug introduced in the latest SDK - I've just updated to Xcode 3.2.4 with iOS SDK 4.1. Has this happened to anyone else? Or perhaps - any idea what could cause this?Thanks!
ArielI found my problem. It wasn't a bug in the new Xcode version, it was my own mistake of course, and thank you guys for trying to help.
The problem was I was initializing my UITabBarItems in the viewDidLoad function of the various view controllers. However, this function was invoked only for the first view controller (the one being displayed) and wasn't invoked for all other view controllers until I touched the relevant tab bar button. And therefore, only when touching the button, the tab bar item was initializing and appearing.
The solution was to initialize the UITabBarItems in the init function of the UIViewController.
Now it all works just fine :-)
Thanks again guys!
Ariel
My answer is strictly for posterity.
Putting in in -(id)init
didn't work for me...
HOWEVER, putting it in (void)awakeFromNib
did because:
1) init isn't called if the nib connections to a UITabBarController are being loaded... 2) awakeFromNib IS called when it is loaded :)
精彩评论