【发布时间】:2017-07-06 01:41:37
【问题描述】:
我在 Storyboard Alpha 上有一个按钮,它使用以下代码通向 Storyboard Beta:
@IBAction func showBeta(_ sender: Any) {
let storyboard = UIStoryboard(name: "Beta", bundle: nil)
let bvc = storyboard.instantiateViewController(withIdentifier: "BetaViewController") as! BetaViewController
self.present(bvc, animated: true, completion: nil)
}
这没有任何问题。
但是,我遇到了在 Beta 版中没有返回按钮的问题,因为 self.present 使新视图以模态方式显示。
然后我阅读了this post,发帖者和我有同样的问题。答案建议使用此代码:
self.navigationController?.pushViewController(viewController: UIViewController, animated: Bool)
所以我将代码更改为:
@IBAction func showBeta(_ sender: Any) {
let storyboard = UIStoryboard(name: "Beta", bundle: nil)
let bvc = storyboard.instantiateViewController(withIdentifier: "BetaViewController") as! BetaViewController
self.navigationController?.pushViewController(bvc, animated: true)
}
但是,现在单击按钮时什么也没有发生。没有错误,什么都没有。这是怎么回事?
【问题讨论】:
-
您的第一个视图控制器是在导航控制器中吗?
标签: ios swift xcode uistoryboard