开发者

How to remove a UITabBarItem

I have a nib with four UIViewControllers each with a UITabBarItem. At runtime, based on user options, I need to show or hide one of the UITabBarItems. I cannot figure out how to remove the UITabBatItem.

Do开发者_Go百科es anyone know how to do this?

Thanks


Christian's code is close. It should be:

NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:myTabBarController.viewControllers];
[viewControllers removeObjectAtIndex:indexToRemove];
[myTabBarController setViewControllers:viewControllers];


To remove one, you can just get the viewControllers from the TabBar and put them in an NSMutableArray. Then remove the index you want removed and then set the viewControllers property to this new array of view controllers using

setViewControllers:animated:

Hoep this helps.


Get the tab bar controller's view controllers, remove the one you want to 'hide' and then set the tab bar controller's viewControllers array to this new array.

NSMutableArray *viewControllers = [myTabBarController viewControllers];
[viewControllers removeObjectAtIndex:indexToRemove];
[myTabBarController setViewControllers:viewControllers animated:YES];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜