[英]How hide back bar button in navigation controller with swift
in the Storyboard (Xcode 6, iOS 8 and swift) i have embedded a TableViewController in a Navigation Controller.在故事板(Xcode 6、iOS 8 和 swift)中,我在导航控制器中嵌入了一个 TableViewController。
From the object library, i have drag & drop a Bar Button Item as the back button and it show an icon image: when i click that button i show a setting view.从对象库中,我拖放了一个 Bar Button Item 作为后退按钮,它显示了一个图标图像:当我单击该按钮时,我显示了一个设置视图。
How can i hide that button?我怎样才能隐藏那个按钮? In the viewDidLoad() i've tried:
在 viewDidLoad() 我试过:
self.navigationItem.hidesBackButton = true;
The code is executed (i've tried with the debugger) but the button is always visible.代码已执行(我已尝试使用调试器),但按钮始终可见。
You have to try this:你必须试试这个:
self.navigationItem.setHidesBackButton(true, animated: false)
hope it helps you.希望对你有帮助。
斯威夫特 3
self.navigationItem.setRightBarButton(nil, animated: true)
If the bar button item is on the right side of the navigation bar you have to set如果栏按钮项位于导航栏的右侧,则必须设置
self.navigationItem.rightBarButtonItems = []
self.navigationItem.rightBarButtonItems = []
if the bar button item in question is on the left side do the same, it will remove the bar button items from the navigation item如果有问题的栏按钮项位于左侧,则执行相同操作,它将从导航项中删除栏按钮项
Try this,尝试这个,
self.navigationItem.setLeftBarButtonItem(nil, animated: true)
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.