ios - Add controller to UITabBarController without new item appearing in the tab bar -
i have application uitabbarcontroller main controller.
when user taps button(not in tab bar, other button), want add new uiviewcontroller inside uitabbarcontroller , show it, don't want new uitabbaritem appear in tab bar. how achieve such behaviour?
i've tried set tabbarcontroller.selectedviewcontroller property view controller not in tabbarcontroller.viewcontrollers array, nothing happens. , if add view controller tabbarcontroller.viewcontrollers array new item automatically appears in tab bar.
update
thanks levi, i've extended tab bar controller handle controllers not present in .viewcontrollers.
@interface maintabbarcontroller : uitabbarcontroller /** * setting property, tab bar controller display * given controller added viewcontrollers , activated * icon not appear in tab bar. */ @property (strong, nonatomic) uiviewcontroller *foreigncontroller; @end #import "maintabbarcontroller.h" @implementation maintabbarcontroller - (void)tabbar:(uitabbar *)tabbar didselectitem:(uitabbaritem *)item { self.foreigncontroller = nil; } - (void)setforeigncontroller:(uiviewcontroller *)foreigncontroller { if (foreigncontroller) { cgfloat reducedheight = foreigncontroller.view.frame.size.height - self.tabbar.frame.size.height; foreigncontroller.view.frame = cgrectmake(0.0f, 0.0f, 320.0f, reducedheight); [self addchildviewcontroller:foreigncontroller]; [self.view addsubview:foreigncontroller.view]; } else { [_foreigncontroller.view removefromsuperview]; [_foreigncontroller removefromparentviewcontroller]; } _foreigncontroller = foreigncontroller; } @end the code correctly set "foreign" controller's view size , remove when user choose item in tab bar.
you either push (if have navigation controller) or add it's view visible view controller's view , add child view controller also.
Comments
Post a Comment