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.
Asked
Active
Viewed 752 times
1

Jeff Kelley
- 19,021
- 6
- 70
- 80
3 Answers
1
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
- 22,363
- 9
- 64
- 71
-
Please post requests for edits/addendum in the comments of the question - unless your request has a chance of actually being an answer. – RickDT Jul 28 '09 at 17:17
-
Well yes it does as i state at the end of my answer, read the whole answer before commenting – Daniel Jul 28 '09 at 17:18
-
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 Jul 29 '09 at 02:59
1
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
- 19,021
- 6
- 70
- 80
0
This happened for me when I set the UIViewController's tabBarItem property in viewDidLoad instead of its init method.

Jeff Ames
- 1,555
- 11
- 27