从选项卡栏控制器中完全删除所有视图控制器
我想从选项卡栏控制器中完全删除所有视图控制器,无论它是否包含,并添加新的视图控制器 在运行时进入 tababr 控制器?可以这样做吗?我已经做了如下,它没有给出输出?
UIViewController *thisIsTheViewControllerIWantToSetNow;
int indexForViewControllerYouWantToReplace;
NSMutableArray *tabbarViewControllers = [self. tabController.viewControllers mutableCopy];
[tabbarViewControllers removeAllObjects];
self.tabController.viewControllers = [NSArray arrayWithObjects:self.moreNavController, self.logInNavController, nil];;
I want to remove all view controllers completly from tabbar controller whether it consists or not, and to add new view controllers
into tababr controller at run time?is it possible to do it?I have done as folowing , it is not giving output?
UIViewController *thisIsTheViewControllerIWantToSetNow;
int indexForViewControllerYouWantToReplace;
NSMutableArray *tabbarViewControllers = [self. tabController.viewControllers mutableCopy];
[tabbarViewControllers removeAllObjects];
self.tabController.viewControllers = [NSArray arrayWithObjects:self.moreNavController, self.logInNavController, nil];;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设给定示例中的
self
是UITabBarController
的实例,那么尝试直接操作其tabbar
是不合适的。而是设置viewControllers
属性。正如
UITabBarController
文档所述:https://developer.apple.com/library/ios/documentation/uikit/reference/UITabBarController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006931-CH3-SW4
Assuming that
self
in the example given is an instance ofUITabBarController
then trying to manipulate itstabbar
directly is not appropriate. Instead set theviewControllers
property.As the
UITabBarController
docs state:https://developer.apple.com/library/ios/documentation/uikit/reference/UITabBarController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006931-CH3-SW4