Under the hood with UITabController

Experimenting with various combinations of UITabController and UINavigationController has lead to some interesting discoveries, some of which may be documented (but I’m not sure where)

If you have a child view controller of a UITabController that is a UINavigationController, it will essentially inherit a UITabBarItem from its root view controller.

When you set up a UITabBarItem for a view controller, make sure you do so in the initializer of the view controller. Do not wait until viewDidLoad. You don’t have to allocate your own UITabBarItem. By default, when you access the tabBarItem property of the view controller for the first time, it will create and return a default tab bar item.

The title for the tab bar item can come from (at least) two different places. You can either explicitly set the title of the tabBarItem itself using its title property. Or, you can set the title of the view controller. If both are set, it seems that whichever is set last wins. So, even if you have explicitly set the title of a tab bar item, if you then change the title of the view controller, that new title will be used for the tab bar item. So, if you don’t want to inherit your view controller’s title for its tab bar item, set the title of the view controller first, then configure your tab bar item.

If you create a system tab bar item, you can’t override its name. You get the icon and the name together.

SplitViewController - the supplied navigation bar item that lets you get back to the master view controller depends on the title property of the master view controller. If that title isn’t set, it will just display an arrow pointing back. If it has a name, there will be the same back arrow, followed by the title.
© 2010-2016 Little Potato Software   Follow littlepotatosw on Twitter        Site Map     Privacy Policy     Contact Me