View Full Version : iPhone SDK help: UITabBarController
Jul 1, 2008, 12:15 AM
I've been having a problem with the iPhone SDK, specifically with the UITabBarController class. Whenever I try to implement a simple two-item TabBarController programmatically, it won't work.
I've found, through some simple debugging, that whenever I assign an array of view controllers to the TabBarController's viewControllers property, the array is actually assigned to the customizableViewControllers property. I cannot, for the life of me, figure out why this is.
I realize that I could just use interface builder, but I prefer to do it programmatically. If anyone has the answer to this question, I will be eternally grateful.
Jul 7, 2008, 06:35 PM
I had the same problem - programmatically creating a UITabBarController did not work the way the Apple documentation described. I found the answer on the Apple developer forum (http://discussions.apple.com/message.jspa?messageID=7444873).
Instead of doing:
tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
tabBarController = [[UITabBarController alloc] init];
Hope this helps.
Jul 8, 2008, 12:10 AM
Thank you so much, dredmuns. I feel really dumb, but I just didn't think of doing that. I hope that documentation gets fixed. It was really aggravating getting errors doing exactly what Apple said to do. But I really appreciate the help. Thanks for responding.
Jul 13, 2008, 08:29 AM
In general, Apple preaches the best practice is to leverage Interface Builder as much as possible (and I agree with that). Unfortunately, Interface Builder wasn't really ready when they built most of their samples... So many of the samples don't use Interface Builder consistently.
I'll predict that getting over that stumbling block (of which I stumbled) will also cause quite a bit of frustration to new iPhone Developers. This post is a perfect example! (Loading a View with a Nib or not)
Jul 14, 2008, 07:27 PM
Are there any fully programmatic or interface builder examples of a tab bar controller implementation. I'd love to see one as a reference that actually works with buttons on each view that link back to something.
I'm afraid I've tried to do things the interface builder way and I get stuck right when I think I've got it.
I can do all of the appropriate view rendering and switching of views but when I try to link IBOutlets or IBActions back to a controller my test app crashes trying to call the super class.