I have a UITabBarController
which containing 4 different UIViewControllers
.
On first tab there is a UINavigationViewController
which contains its child UIViewController
. without tapping the tab bar, i want to take user on second tab. For this I tried:
self.navigationController.tabBarController.selectedIndex = 1;
But it's not working.
ignore any mistake i am a newbie.
Thank you.
if set delegate Try this:
self.selectedIndex = 1;
You are the tabBarController :)
Do the following, before trying to change tab:
UITabBarController *tab = self.tabBarController;
if (tab) {
NSLog(@"I have a tab bar");
[self.tabBarController setSelectedIndex: 1];
}
else {
NSLog(@"I don't have one");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With