Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ari.ehrmann

macrumors newbie
Original poster
Jun 30, 2008
2
0
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.

Thanks
 

dredmuns

macrumors newbie
Jul 7, 2008
1
0
UITabBarController

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:

Code:
tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];

do just:

Code:
tabBarController = [[UITabBarController alloc] init];

Hope this helps.
 

ari.ehrmann

macrumors newbie
Original poster
Jun 30, 2008
2
0
Thanks

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.
 

dgdosen

macrumors 68030
Dec 13, 2003
2,740
1,380
Seattle
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)
 

Hazmit

macrumors newbie
Jul 14, 2008
1
0
Interface Builder is not better

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.