hpique
hpique

Reputation: 120324

Detect when UITabBarController More tab is selected

How can I detect when the special More tab of UITabBarController is selected?

tabBarController:didSelectViewController: tells me when a tab was selected, including the More tab. However, how can I know that the given UIViewController is actually the More tab?

At first I though about using the index, but that would assume that the More tab will be in the same position. Also, the title ("More") appears to be localised.

Upvotes: 3

Views: 1720

Answers (2)

user529758
user529758

Reputation:

An alternative approach:

if (tabBarController.selectedIndex == NSNotFound) {
    // etc.
}

Upvotes: 2

hpique
hpique

Reputation: 120324

Found it right after posting the question:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController 
{
    if (tabBarController.moreNavigationController == viewController) {
        NSLog(@"More");
    }
}

Upvotes: 4

Related Questions