UITabbarController selectedIndex and selectedViewController do not work

廉价感情. 提交于 2019-12-06 07:11:16

Solution: Try by moving your,

self.tabBarController.selectedIndex = 3;
self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:3];

portion of your code to UIVIewController's

- (void)viewDidAppear:(BOOL)animated

I hope it will help you

Reason: You have to let your UIViewController to load fully first before you trigger an extra action on it.

Try this definitely it works:

 UINavigationController *nc = [[self.tabBarController viewControllers] objectAtIndex:0];
id vc = [[nc viewControllers] objectAtIndex:0];
if ([vc isKindOfClass:[YourViewController class]])
{
    [[self appDelegate].tabBarController setSelectedIndex:3];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!