简体   繁体   中英

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.

Found it right after posting the question:

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

An alternative approach:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM