Search code examples
iosuitabbaritemappdelegate

How to open the third tab bar item when my application launches?


I'm working on a tab bar application with five items in it and I want to open the third view controller which is associated to the third tab bar item when my application launches instead of the first one which opens by default. How can I approach this?

Here's the code I'm using:

In myappdelegate.h

@property (nonatomic, retain) IBOutlet   FirstViewController *firstView;

In myappdelegate.m

[window addSubView:firstView.view];

This doesn't work.


Solution

  • you can use bellow code to display the 3 tab of UITabBar at first...

    self.window.rootViewController = self.tabBarController;
    self.tabBarController.selectedIndex = 2;