Reputation: 313
I have the same exact problem that appears in the following link
How to segue from UIButton to a Tab Bar Item?
and unfortunately I couldn't find any solution till now
Notes :
1) I'm using iOS 5 with a storyboard -if make a difference-
2) I've tried [self.tabBarController.tabBar setSelectedItem:[self.tabBarController.tabBar.items objectAtIndex:3]];
and also it does not work
3) I've tried to set IBOutlet for the tab bar and access it directly, but the app was crashed when I called [self.myTabbar setSelectedItem:[self.myTabbar.items objectAtIndex:3]];
and got this error : Directly modifying a tab bar managed by a tab bar controller is not allowed
Upvotes: 0
Views: 9738
Reputation: 1592
To start on a tabBarItem
place in AppDelegate
[(UITabBarController *) self.window.rootViewController setSelectedIndex: 2];
so RootViewController
automatically starts viewController
Upvotes: 4
Reputation: 313
OMG, it's like a magic, the solution is :
[(UITabBarController*)self.navigationController.topViewController setSelectedIndex:3];
I get the solution from the following post: https://stackoverflow.com/a/10533414/1150618
Upvotes: 18