我有 VC1,它是一个基本的 View Controller ,然后我想展示在导航 Controller 中的 VC2。每当我展示它时,它都不会显示导航 Controller 。我希望这一切都务实地完成。我用来展示 VC2 的代码是:
func matchesPressed(sender: UIButton!) {
let matchesTVC: Matches = self.storyboard?.instantiateViewControllerWithIdentifier("Matches") as! Matches
self.presentViewController(matchesTVC, animated: true, completion: nil)
}
如何显示它内部的导航 Controller ?
最佳答案
Storyboard中是否有导航 Controller ?如果是这样,给它一个 Storyboard ID 并将你的 matchesTVC
内容替换为导航 Controller 。
如果 matches 是 Storyboard中的独立 View Controller ,您可以使用如下代码来实现:
let matchesTVC: Matches = self.storyboard?.instantiateViewControllerWithIdentifier("Matches") as! Matches
let navContr = UINavigationController(rootViewController:matchesTVC)
self.presentViewController(navContr, animated: true, completion: nil)
关于swift - 如何在导航 Controller SWIFT 中呈现 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29974858/