iPhone SDK help: UITabBarController

Discussion in 'iOS Programming' started by ari.ehrmann, Jun 30, 2008.

  1. ari.ehrmann macrumors newbie

    Jun 30, 2008
    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.

  2. dredmuns macrumors newbie

    Jul 7, 2008

    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];
    do just:

    tabBarController = [[UITabBarController alloc] init];
    Hope this helps.
  3. ari.ehrmann thread starter macrumors newbie

    Jun 30, 2008

    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.
  4. dgdosen macrumors 65816


    Dec 13, 2003
    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)
  5. Hazmit macrumors newbie

    Jul 14, 2008
    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.

Share This Page