Reputation: 5426
i used the code below to make a UITabBarController :
inside AppDelegate.h
:
IBOutlet UITabBarController *rootController;
...
@property (nonatomic, retain) IBOutlet UITabBarController *rootController;
inside AppDelegate.m
@synthesize rootController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[self.window addSubview:rootController.view];
[self.window makeKeyAndVisible];
return YES;
}
Now i need to know how to implement this method inside AppDelegate:
- (void)SwitchToTab:(int)index{
//go to tabview 1 or 2 ...
}
Upvotes: 2
Views: 1155
Reputation: 124997
You can do this:
self.rootController.selectedIndex = 2; // or whatever index you like
or this:
self.rootController.selectedViewController = oneOfTheViewControllersInTheTabController;
See the UITabBarController reference page for details.
Upvotes: 4