In navigation controller, I from 客户管理
push to 客户详情
.
How can I hide the 客户管理
(navigationBar back button title)?
In navigation controller, I from 客户管理
push to 客户详情
.
How can I hide the 客户管理
(navigationBar back button title)?
Try this:
Add this code after @end in appDelegate :
@implementation UINavigationItem (additional)
-(UIBarButtonItem *)backBarButtonItem
{
return [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
}
@end
In the interface builder, you can select the navigation item of the previous controller and change the Back Button
string to what you'd like the back button to appear as. If you want it blank, for example, just put a space.
You can also change it with this line of code:
[self.navigationItem.backBarButtonItem setTitle:@"Title here"];
Or in Swift:
self.navigationItem.backBarButtonItem?.title = ""
If you want to hide that for whole app then try this one:
extension UINavigationItem {
func backBarButtonItem() -> UIBarButtonItem {
return UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
}
}
And if you want to hide that for particular view then write below code.
self.navigationItem.backBarButtonItem?.title = ""
You can remove the title of that button as below
navigationItem.backBarButtonItem?.title = ""
Also, if you are looking to hide it everywhere you can create an extension for UINavigationController.
There are many ways to do that but easiest way that always works without any problem is:
let backItem = UIBarButtonItem()
backItem.title = " "
navigationItem.backBarButtonItem = backItem
You just need to copy and paste this code inside your viewDidLoad.