其他解决办法似乎不起作用。
我正在使用一个MasterView应用程序,以防万一这很重要。
我希望在“detailViewController”上没有导航栏,也不希望在后续的ViewControllers上使用“Show”导航栏来实现。
下面是DetailViewController:
Class DetailViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.setToolbarHidden(true, animated: true)
configureView()
}
configureView() {
// Some UI Stuff
}
}导航栏还在。
在MasterViewController中,这是prepareForSegue:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDetail" {
if let indexPath = tableView.indexPathForSelectedRow {
if isFiltering() == true {
let building = filteredBuildings[(tableView.indexPathForSelectedRow?.row)!]
let controller = (segue.destination as! UINavigationController).topViewController as! DetailViewController
controller.detailBuilding = building
controller.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem
controller.navigationItem.leftItemsSupplementBackButton = true
rating = filteredBuildings[(tableView.indexPathForSelectedRow?.row)!].rating
print("rating was changed to \(rating)")
} else {
let building = buildings[indexPath.row]
let controller = (segue.destination as! UINavigationController).topViewController as! DetailViewController
controller.detailBuilding = building
controller.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem
controller.navigationItem.leftItemsSupplementBackButton = true
rating = buildings[indexPath.row].rating
print("rating was changed to \(rating)")
}
}
}
}发布于 2018-09-18 03:39:48
隐藏导航条工具栏不同于隐藏导航条本身。如果要隐藏工具栏,可以尝试@Anbu.karthik在注释中建议的内容。但是,如果您想要隐藏导航栏,则需要使用它。
navigationController?.setNavigationBarHidden(true, animated: true)发布于 2018-09-18 03:58:37
self.navigationController?.setNavigationBarHidden(true,动画:真)
https://stackoverflow.com/questions/52378388
复制相似问题