views:

260

answers:

2

I've got a UITabBarController in my project that I'm creating programmatically - without a nib. I create the view controllers, initialize them, and then create an array of them and use the setViewControllers:animated: method on my tab bar controller. This works except that when it appears, my tab bar controller doesn't have anything selected. If I call [ tabBarController setSelectedIndex:1 ], then it works just fine, but if I call [ tabBarController setSelectedIndex:0 ], nothing is selected. Is this a weird bug or am I doing it wrong? This is using the iPhone SDK 3.0.

+1  A: 

Show your code if you will, will make it easier for us to find the problem...But from not seeing anything, what I would think is wrong is that when you initialize your UITabBarButtons you are not giving any of them an index of 0...

Daniel
Please post requests for edits/addendum in the comments of the question - unless your request has a chance of actually being an answer.
RickDT
Well yes it does as i state at the end of my answer, read the whole answer before commenting
Daniel
I'm not finding that I need to initialize any UITabBarButtons or set their indices; it's taken care of automatically by the UITabBarController.
Jeff Kelley
A: 

It turns out that the code was written by me a long time ago, when I did stupid things like override the -tabBarItem accessor method in the UIViewController. Moving the tab bar item customization to -initWithStyle: fixed this problem.

Jeff Kelley