UITabbarController selectedIndex and selectedViewController do not work
ios, objective-c, uitabbarcontroller
Solution
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.
Problem
I've tried to put following two lines into `- (void)viewDidLoad.` ``` self.tabBarController.selectedIndex = 3; self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:3]; ``` At that time, only Tabbar index to change 3 but View Controller remained at default view controller, mean 0. Is there any thing missing in my coding?