首页 > 其他 > 详细

storyboard时动态改变tabbarcontroller上tabbar数量

时间:2015-03-04 11:06:33      阅读:495      评论:0      收藏:0      [点我收藏+]

假如你是使用storyboard上构建的tabbarcontroller,TabbarController上有3个item这时候你想在代码里动态变更成2个,保留第一个和第三个,去掉中间一个,怎么办?

只需要用以下代码就搞定了:

    UITabBarController *tabBarController = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
    NSMutableArray *tabbarViewControllers = [NSMutableArray arrayWithArray: [tabBarController viewControllers]];
    [tabbarViewControllers removeObjectAtIndex:1];
    [tabBarController setViewControllers: tabbarViewControllers ];


storyboard时动态改变tabbarcontroller上tabbar数量

原文:http://blog.csdn.net/dauihiy/article/details/44056731

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!