[英]Hide back button on iOS 11.2.2
I'm trying to hide the back button of the Navigation Bar. 我正试图隐藏导航栏的后退按钮。 I can do that in all iOS versions older than iOS 11.2.2
我可以在iOS 11.2.2之前的所有iOS版本中执行此操作
I've already tried the following code: 我已经尝试过以下代码:
self.navigationController?.navigationItem.setHidesBackButton(true, animated: true)
self.navigationController?.navigationItem.hidesBackButton = true
self.navigationItem.setHidesBackButton(true, animated: true)
self.navigationItem.hidesBackButton = true
Nothing seems to work in iOS 11.2.2 在iOS 11.2.2中似乎没有任何作用
I'm using Xcode 9 and Swift 4 我正在使用Xcode 9和Swift 4
I am using Xcode9, Swift 4 & iOS 11.2 and 我正在使用Xcode9,Swift 4和iOS 11.2和
self.navigationItem.hidesBackButton = true
works completely fine. 工作得很好。
Swift 4 Xcode 9.2 Swift 4 Xcode 9.2
Suggest that I am moving From A controller to B Controller and i embed navigation controller before A. In controller B i write this code and its work fine. 建议我从A控制器移动到B控制器,然后在A之前嵌入导航控制器。在控制器B中我编写此代码并且其工作正常。
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.setHidesBackButton(true, animated: true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Its worked for me. 它对我有用。
override func prepare(for segue: UIStoryboardSegue, sender: Any?){
if segue.identifier == "viewcontroller"{
let objVC = segue.destination as? viewcontroller
objVC?.navigationItem.hidesBackButton = true
}
}
You set the hidesBackButton
attribute before present, or push hided back button view controller. 您可以在
hidesBackButton
之前设置hidesBackButton
属性,或者按下hidesBackButton
后退按钮视图控制器。
@objc func showHidedBackButtonViewController() {
navigationItem.hidesBackButton = true
let hidedBackButtonViewController = HidedBackButtonViewController()
navigationController?.pushViewController(hidedBackButtonViewController, animated: true)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.