Selected index in the "more" UITabbar view

How can I control user selections in the "more" UITabBar view? I have this code for managing UITabBarItems selections:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {    
    if (!(viewController == tabBarController.moreNavigationController)) {
        int index = tabBarController.selectedIndex;
        [[DataManager sharedInstance] setCurrentTabbarIndex:index];
    }
}

It works great for visible elements of UITabBarItems, but when a user selects an element from a "larger" view, I never get any information about it. Is there a way to catch the selection of the user element as "larger"? Thank!

+5
source share
4 answers

The "more" view of the UITabBarController is handled separately from other views. Apple's discussion on the subject reads as follows:

[ "moreNavigationController" ] , "" . , More .

, , . "" . More , viewControllers. More .

, , - :

int index = tabBarController.selectedIndex;
if (tabBarController.selectedViewController == 
    tabBarController.moreNavigationController) {
    index = -1;  //assign some placeholder index for the "More" controller
}
+2

, , - .

, "" . , UITabBarControllerDelegate, .h :

@interface MyDelegate : NSObject <UITabBarControllerDelegate, UINavigationControllerDelegate>
{
}

, :

- (void) assignDelegate:(MyDelegate)myDelegate toTabBarController:(UITabBarController*)tabBarController
{
  tabBarController.delegate = myDelegate;
  tabBarController.moreNavigationController.delegate = myDelegate;
}

, , :

- (void) navigationController:(UINavigationController*)navigationController didShowViewController:(UIViewController*)viewController animated:(BOOL)animated
{
     // add code to handle the event
}

, .

+2

, , - UITableView, topViewController UITabBarController.moreViewController. didSelectRowAtIndexPath !

( ) : http://initwithstyle.net/2014/02/making-more-of-the-more-view/

+1

No matter which view you choose, you will get viewWillAppear:animated:

Provide this in all the views that are controlled by your tab bar, and you can thus retrieve the user ID, even if it is made from the More controller.

You can save the state of the tab bar directly in this method, or you can submit your images back to the tab bar and notify about it.

0
source

All Articles