Your use of UITabBar
is not correct for what you are trying to accomplish. The standard use of a UITabBar
is in the context of a UITabBarController
.
Here is a sample use of tab bars.
1) Create a UITabBarController
and set it as the rootViewController
of your window
in your AppDelegate
.
2) Assign the viewControllers
property of the tab bar controller to be an array of the view controllers you want to be able to switch between (which you must also create).
3) You will need to do some additional research if you want to style the different aspects of the tab bar. Some things are styled by accessing the tabBar
property of the UITabBarController
directly. Other things (like individual tab icons and titles) are set by using the tabBarItem
property of each view controller.
4) If you want to encapsulate all of this logic into one place and potentially change some of the default logic, subclass UITabBarController
.
edit: your question has changed a bit and I'm not sure this answer is valid anymore. That said, it sounds like you are also misusing the UINavigationBar
as this is not really its intended purpose (perhaps you meant to use a UIToolBar
?)