本文翻译自:How to hide 'Back' button on navigation bar on iPhone?
I added a navigation control to switch between views in my app. 我添加了一个导航控件,可以在我的应用中切换视图。 But some of the views shouldn't have 'Back' (the previous title) button. 但有些观点不应该有“后退”(前一个标题)按钮。 Any ideas about how to hide the back button? 有关如何隐藏后退按钮的任何想法?
#1楼
参考:https://stackoom.com/question/2Zme/如何隐藏iPhone导航栏上的-后退-按钮
#2楼
使用代码:
self.navigationItem.backBarButtonItem=nil;
#3楼
The best way is to combine these, so it will hide the back button even if you set it up manually : 最好的方法是组合这些,所以即使你手动设置它也会隐藏后退按钮:
self.navigationItem.leftBarButtonItem=nil;
self.navigationItem.hidesBackButton=YES;
#4楼
hide back button with bellow code... 用波纹管代码隐藏后退按钮...
[self.navigationItem setHidesBackButton:YES animated:YES];
or 要么
[self.navigationItem setHidesBackButton:YES];
Also if you have custom UINavigationBar
then try bellow code 此外,如果你有自定义UINavigationBar
然后尝试下面的代码
self.navigationItem.leftBarButtonItem = nil;
#5楼
在UIViewController的函数viewDidLoad中使用代码:
self.navigationItem.hidesBackButton = YES;
#6楼
In Swift : 在Swift中 :
Add this to the controller 将其添加到控制器
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.setHidesBackButton(true, animated: false)
}