BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / mobile-terminal-at / #14557同步于 2014/6/12
该镜像源已超过 30 天没有更新,可能在源站已被删除。
MobileTerminalAT机器人发帖

求问ios TabBar默认选中的问题

AsPolaris
2014/6/12镜像同步5 回复
在UITabBarViewController中设置self.selectedIndex=0并没有默认选中,效果如下图 但设置self.selectedIndex=1就有默认选中效果了 再次点击TabBarItem后就正常了 查了很多都没有解决,实在是不解啊!求助!先行谢过! UITabBarViewController中设置代码: NSMutableArray *items=[[NSMutableArray alloc]init]; MessageViewController *messageViewController=[[MessageViewController alloc]init]; ChannelViewController *channelViewController=[[ChannelViewController alloc]init]; MoreViewController *moreViewController=[[MoreViewController alloc]init]; [items addObject:messageViewController]; [items addObject:channelViewController]; [items addObject:moreViewController]; [self setTitle:@"main"]; [self setViewControllers:items animated:YES]; [self.selectedIndex=1;
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
ps0772机器人#1 · 2014/6/13
按着楼主写的坐。。完全木有问题 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. NSMutableArray *items=[[NSMutableArray alloc]init]; MessageViewController *messageViewController=[[MessageViewController alloc]init]; ChannelViewController *channelViewController=[[ChannelViewController alloc]init]; MoreViewController *moreViewController=[[MoreViewController alloc]init]; [items addObject:messageViewController]; [items addObject:channelViewController]; [items addObject:moreViewController]; [self setTitle:@"main"]; [self setViewControllers:items animated:YES]; self.selectedIndex=2; }
ps0772机器人#2 · 2014/6/13
只是下面的选中效果的问题吧,选中图片切换的问题?。。贴的代码是没有问题的吧
apocalypse机器人#3 · 2014/6/13
【 在 ps0772 的大作中提到: 】 : 只是下面的选中效果的问题吧,选中图片切换的问题?。。贴的代码是没有问题的吧 re selectedindex = 0 已经生效了 0index的vc出来了 按钮ui似乎有问题
ps0772机器人#4 · 2014/6/13
是这样子的 【 在 apocalypse 的大作中提到: 】 : : re selectedindex = 0 已经生效了 0index的vc出来了 : 按钮ui似乎有问题
AsPolaris机器人#5 · 2014/6/13
呃是selectedIndex=0时候出问题了,后来每一个vc嵌套了一个navigationController就好了。。我也不知道为啥。。thanks anyway! 【 在 ps0772 的大作中提到: 】 : 按着楼主写的坐。。完全木有问题 : - (void)viewDidLoad : { : ...................