Reputation: 91
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.
Upvotes: 3
Views: 2598
Reputation: 13549
In the viewWillAppear method of that viewController set the visible tab:
self.yourTabBarController.selectedViewController = [yourTabBarController.viewControllers objectAtIndex:2];
Upvotes: 3
Reputation: 17902
Use the methods above but if you want it to happen with the application launches you need to use -(void) awakeFromNib {
That function is called when you press the app icon on your devices home screen.
viewDidLoad is called after your Default.png has been displayed.
Upvotes: 0
Reputation: 20551
you can use bellow code to display the 3 tab of UITabBar at first...
self.window.rootViewController = self.tabBarController;
self.tabBarController.selectedIndex = 2;
Upvotes: 11