0

I've been trying to remove the "edit" button than appears on top right corner of in "more" section of UITabBarController, by adding TabBarController class to it and do the following inside:

class TabBarController: UITabBarController, UINavigationControllerDelegate, UITabBarControllerDelegate {

override func viewDidLoad() {
    super.viewDidLoad()

    self.moreNavigationController.delegate = self
    self.customizableViewControllers = nil
    self.moreNavigationController.navigationItem.rightBarButtonItem?.isEnabled = false
    self.moreNavigationController.navigationBar.topItem?.rightBarButtonItem = nil
}
}

But this doesn't work. The edit button still appears.

How can I remove this edit button?

Emad
  • 346
  • 1
  • 6
  • 17

2 Answers2

3

Set a class for your main UITabBarController. Then in viewdidload, specify that none of your controllers are customizable.

class MainTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.customizableViewControllers = []
    }

}

enter image description here

GIJoeCodes
  • 1,680
  • 1
  • 25
  • 28
1

The answer in this post helped me solve it as suggested by @Surjeet.

For Swift 3 people here is the function that needs to be added in order to remove the button:

func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
    let morenavbar = navigationController.navigationBar
    if let morenavitem = morenavbar.topItem {
        morenavitem.rightBarButtonItem = nil
    }
}
Emad
  • 346
  • 1
  • 6
  • 17