How to change initial tab bar selection programmatically How to change initial tab bar selection programmatically objective-c objective-c

How to change initial tab bar selection programmatically


Since this is the initial view controller, and is not a subclass, you need to set this in your appDelegate.

In AppDelegate.m, add the following to your application:didFinishLaunchingWithOptions: method:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    // Override point for customization after application launch.    // Select the left-most tab of our initial tab bar controller:    UITabBarController *tabBar = (UITabBarController *)self.window.rootViewController;    tabBar.selectedIndex = 0;    return YES;}


tabBar setSelectedItem: try using this in your viewDidLoad