user1416564
user1416564

Reputation: 401

Unwind Navigation Controller on when switching tabs

My setup is follows: I have a TabBarController at the root initial view and the following tabs: TabViewController1 and MoreMenuViewController. The More Menu View controller has an embedded UIVNavigationController which has a button that pushes SettingsViewController into view.

UITabbarController -> UINavigationController -> TabViewController1
UITabbarController -> UINavigationController -> MoreMenuViewController -> SettingsViewController

Now, assume I am in the SettingsViewController. I click the tab to go to TabViewController1. When I click the tab to go to MoreMenuViewController I am shown SettingsViewController instead. I'd like it to show MoreMenuViewController on tab switch.

I am using iOS8 and XCode6 with Storyboards.

Upvotes: 1

Views: 321

Answers (1)

Aleksander Grzyb
Aleksander Grzyb

Reputation: 789

In your MoreMenuViewController you can implement UITabBarControllerDelegate method like this:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    [self.navigationController popViewControllerAnimated:NO];
}

Moreover you need to set MoreMenuViewController to be delegate of UITabBarControllerDelegate (for example in viewDidLoad method) via:

self.tabBarController.delegate = self;

Upvotes: 2

Related Questions