How to disable the edit button that appears in the more section of a UITabBarController?

前端 未结 16 1007
借酒劲吻你
借酒劲吻你 2020-12-02 11:30

In my application (based on the Tab bar application XCode template) I use a UITabBarController to display a list of different sections of the application that the user can a

16条回答
  •  执笔经年
    2020-12-02 12:06

    i have tried and here's a example.

    In AppDelegate.m

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
        // Override point for customization after application launch.
    
        // Add the tab bar controller's view to the window and display.
        [self.window addSubview:tabBarController.view];
        [self.window makeKeyAndVisible];
    
        //setting delegate to disable edit button in more.
        tabBarController.moreNavigationController.delegate = self;
    
        return YES;
    }
    

    to remove the "Edit" Button

        - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
            UINavigationBar *morenavbar = navigationController.navigationBar;
            UINavigationItem *morenavitem = morenavbar.topItem;
            /* We don't need Edit button in More screen. */
    morenavitem.rightBarButtonItem = nil;
    }
    

    In your AppDelegate.h

    @interface TestAppDelegate : NSObject 
    

    correct me if i'm wrong.

提交回复
热议问题