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.
views:
260answers:
2
+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
2009-07-28 17:12:54
Please post requests for edits/addendum in the comments of the question - unless your request has a chance of actually being an answer.
RickDT
2009-07-28 17:17:38
Well yes it does as i state at the end of my answer, read the whole answer before commenting
Daniel
2009-07-28 17:18:20
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
2009-07-29 02:59:09
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
2009-07-29 02:57:48