1
votes

I am using tab bar controller to show my views, since i have exceeded 5 tabs, all other view automatically move more navigation controller of tabbarcontroller.

My main goal is to remove back button text in all the views present inside the more navigation controller . I tried all possible ways of removing the text . Please help me resolving the the issue .

self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)


tabBarController!.moreNavigationController.navigationBar.backItem?.title = "";

Please refer my attached screenshot . This is the page am getting from moreNAvaigation controller . So iw ant hide back button text and for it's child views also

enter image description here

4

4 Answers

3
votes

I just ran into this same issue and found this answer via Google. The selected answer didn't work for me, so I did some digging and was able to figure this out. Setting the backBarButtonItem property on the navigation item for moreNavigationController will not do anything, there is another hidden view controller that you need to use...

If you take a look at moreNavigationController.viewControllers in the debugger you will see that there is a view controller already in the array called UIMoreListController. You need to set the backBarButtonItem property on the UIMoreListController instance for this to work.

This should work (in a UITabBarController subclass):

if let moreList = moreNavigationController.viewControllers.first(where: { String(describing: type(of: $0)) == "UIMoreListController" }) {
  moreList.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
}
2
votes

self.navigationItem.hidesBackButton = true

2
votes

In your Source ViewController add below code to viewWillAppear

self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)

From this view controller you need to move to destination view controller as follows :

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destinationViewController:UIViewController  = storyboard.instantiateViewControllerWithIdentifier("DetailView") as! UIViewController
self.navigationController?.pushViewController(destinationViewController, animated: true)
1
votes

Just go with the leftBarButtonItem

self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)

OR

self.navigationItem.leftBarButtonItem = nil