matthias matthias - 1 year ago 80
iOS Question

tabBarController is nil; can't change selectedIndex on viewDidLoad

I have a UITabBarController like this:

@interface SomeTabBarController: UITabBarController

and in the SomeTabBarController.m i want to change the active tab on 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...


Answer Source

Try this:

    self.selectedIndex = 1;

You are the tabBarController :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download