Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tabBarController is nil; can't change selectedIndex on viewDidLoad

I have a UITabBarController like this:

/*SomeTabBarController.h*/
@interface SomeTabBarController: UITabBarController
@end

and in the SomeTabBarController.m i want to change the active tab on viewDidLoad

-(void)viewDidLoad
{
  [super viewDidLoad];
  self.tabBarController.selectedIndex = 2;
}

However, tabBarController is nil. What am i missing? I have a navigation controller and segue push to the tab bar controller...

Thx

like image 303
matthias Avatar asked Nov 27 '22 07:11

matthias


1 Answers

Try this:

self.selectedIndex = 1;

You are the tabBarController :)

like image 97
fguchelaar Avatar answered Dec 09 '22 17:12

fguchelaar