我有显示视图控制器,该视图具有后视图和前视图,后视图是我的侧面菜单,问题是当我从侧面菜单中点击菜单项时,它显示了目标视图控制器,但未显示导航栏。请帮我。我是iOS的新手。 这是我的故事板图片: https://imgur.com/a/PbDygKO
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
itemIndex = indexPath.row
self.revealViewController().revealToggle(animated: true)
performSegue(withIdentifier: "webview", sender: nil)
}
这是在“准备”功能上
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let navigationController = segue.destination as? UINavigationController, let progressWebViewController = navigationController.topViewController as? ProgressWebViewController else {
return
}
switch itemIndex {
case 1:
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "aboutus") as! AboutUsController
self.present(newViewController, animated: true, completion: nil)
break
case 2:
loadURL(progressWebViewController: progressWebViewController ,url: "https://google.com", title: "Event Planning")
case 3:
loadURL(progressWebViewController: progressWebViewController ,url: "https://google.com", title: "NCC Checklist")
default:
print("Unknown segue \(itemIndex)")
}
}
答案 0 :(得分:0)
是因为此行:
self.present(newViewController, animated: true, completion: nil)
当您呈现一个viewController时,它具有模式行为,并且没有navigationController
因此,如果您需要使用navigationController,则应改用pushViewController
像这样:self.navigationController.pushViewController(newViewController, animated: true)