简体   繁体   English

如何快速隐藏导航控制器中的后退栏按钮

[英]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.

相关问题 使用 Swift 中的 hidesBackButton 在导航栏中隐藏后退按钮 - Hide back button in navigation bar with hidesBackButton in Swift Swift 5 - 如何在没有后退按钮的情况下隐藏导航栏中的后退按钮或移动到另一个屏幕 - Swift 5 - How to hide back button in Navigation bar or move to another screen without back button Swift / XCode 6.4:向导航栏中的导航控制器添加后退按钮 - Swift/XCode 6.4: add back button to navigation controller in navigation bar 如何隐藏导航栏后退按钮? - How to hide navigation bar back button? 如何隐藏 iPhone 导航栏上的“返回”按钮? - How to hide 'Back' button on navigation bar on iPhone? Swift - 如何隐藏导航项中的后退按钮? - Swift - How to hide back button in navigation item? 隐藏导航栏但不隐藏后退按钮 - Hide Navigation Bar but not the back button 迅速按下导航栏后退按钮时重新加载视图控制器2 - Reloading view controller when navigation bar back button is pressed in swift 2 是否可以隐藏导航栏但在视图控制器上保留后退按钮? 如果是这样怎么办? - Is it possible to hide navigation bar but keep back button on view controller? If so how? Swift:如何隐藏标签栏控制器的第一个视图控制器上的后退按钮? - Swift: how to hide back button on the first view controllers of tab bar controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM