Hide tab bar item and aligning other tab items

旧城冷巷雨未停 提交于 2020-02-01 04:39:08

问题


In my app, i have 4 tab bar items. Iam adding these 4 tab bar items in XIB file.

Initially i have to show 3 tab bar items and after sync i have to show 4th tab bar item in my app. So for this, i am hiding 4th Tab bar item using following code.

[[[self.tabBarController.tabBar subviews] objectAtIndex:03 setHidden:YES];

The tab item is hiding but i am having blank space in place of the hidden item. Is there any chance to align other 3 items in full tab bar. The thing is i dont want to show blank space or empty space in tab bar.

Thanks Jithen


回答1:


If you want to get the items of the tabBar rearranged you have to remove the controller from the controllers list, not hide it. You can use this code to achieve this:

NSMutableArray *controllers = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[controllers removeObjectAtIndex:3];
[self.tabBarController setViewControllers:controllers animated:YES];


来源:https://stackoverflow.com/questions/15985869/hide-tab-bar-item-and-aligning-other-tab-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!