Reputation: 366
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?
Upvotes: 0
Views: 820
Reputation: 1850
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 = []
}
}
Upvotes: 3
Reputation: 366
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
}
}
Upvotes: 1