I have a UITabBarController
which containing 4 different UIViewControllers
.
On first tab there is a UINavigationViewController
Try moving your tab switch code to viewDidLoad
I verified that this works on the built in Tabbed Application template project in xcode 4
- (void)viewDidLoad
{
[super viewDidLoad];
self.tabBarController.selectedIndex = 1;
}
I'd also take a look at your AppDelegate class for something along the lines of this
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
If you don't see these lines anywhere then you'll want to find where else in your code the UITabBarViewController is being initialized and use that object pointer instead.