Hello all, I have an app with a navigation controller that I would like to add a tab bar to. Does anybody know if its possible to say something like if the fist tab is selected show view1 if tab 2 is selected show view2? If theres code for that then I would be good to go. Any help is appreciated. Y+Thanks
views:
465answers:
3Why do you not want to use a TabBarController?
Otherwise you can simply add a tabbar and implement the UITabBarDelegate protocol to react to changes. Which is essentially implementing your own TabBarController.
You will need to create a Tabbar and set the delegate to an object that implements the following method, where you can switch view based on the selected tabbarItem:
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
int index = [tabBar.items indexOfObject:item];
switch (index) ...
}
You shouldn't be using a UITabBarView
without a UITabBarViewController
.
According the interface guidelines, a tabbar should always be at the top level of the app. In other words, you should have a tabbar and then have a navigation controller inside each tab.
If you need to display views as with a tabbar but not at the top level of the app, use a segmented control. Users will understand they are choosing alternate views but they won't be confused about where in the app they are.