需求
在app中任意一个页面,点击某个功能按钮的时候, app
都要选中第三个tab
遇到的问题
选中第三个tab的时候,底部tab消失了
问题代码
[getCurrentNavgationCotroller() popToRootViewControllerAnimated:YES];
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
MLTabBarViewController *tabVC = delegate.rootBottomBar;
tabVC.selectedIndex = 3;
执行过上面的代码之后,是切换到了第三个tab, 但是底部的
tabbar 却不见了
原因: 因为 [getCurrentNavgationCotroller() popToRootViewControllerAnimated:YES]; 这句代码
我们执行了返回动画结束之后,底部tabbar才会出现,
在动画没有结束的时候,我们就执行了 tabVC.selectedIndex = 3;
,导致底部tabbar 展示不出来
正确代码
[getCurrentNavgationCotroller() popToRootViewControllerAnimated:NO];
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
MLTabBarViewController *tabVC = delegate.rootBottomBar;
tabVC.selectedIndex = 3;
将动画去掉,直接返回,然后在选中第三个tab, 这样就
没有问题了