views:

235

answers:

1

Hi Huys,

The senario is, I a TabbarViewController, which contains Tab {A, B, C, D}. After User clicked Tab:B, instead Tab {A, B, C, D}, I want show {E, F, G} as the Tabbar item on the Tabbar.

Is there any way to switch Tabbar Item Set? I'm a newbie to iOS. Thanks!

EDIT: I've also tried to modify self.tabbarcontroller.tabbar.items, but I got a runtime exception, said that tabbar.items cannot be modified directly.

\EDIT Found a way to solve this scenario: Use a navigation controller, and push a TabbarView which uses {A, B, C, D}, and if B is touched, push another TabbarView to the navigation controller
@joelm thanks for your help!

Greeting, Stellit

A: 

The UITabBarController maintains an array of ViewControllers which correspond to the buttons the user sees. You can change a controller, but beware that that will cause the tabBarController to reload All the controllers which might not be what you want.

joelm
how can I change the controller? can I change them back afterwards? Or is there any way that allows me hide tab bar with item {A, B, C, D} and show them again when I want?
Stellit
I strongly suggest you read the documentation for UITabBarController, it tells you that you can't modify the tabbar, its only there for reference. But you can swap out the view controllers as often as you want and you can cover up the tabbar whenever you'd like. Just replace a viewController in the viewControllers property. The 'root view' can't cover the tabbar itself. (if it did you'd never be able to uncover the tabbar.) So I suggest adding a new view that covers the tabbar and then can be removed when you want to show the tabbar again.
joelm
Found a way to solve this scenario: Use a navigation controller, and push a TabbarView which uses {A, B, C, D}, and if B is touched, push another TabbarView to the navigation controllerThanks joelm
Stellit