【发布时间】:2015-01-08 21:06:34
【问题描述】:
我正在尝试编写一个简单地切换到下一个视图的按钮。所以我将第一个 ViewController 嵌入到导航控制器中,然后我拖入另一个视图控制器,创建了一个新的类名称 ViewController2 并将该类与第二个 ViewController 相关联,并为第二个视图控制器提供了故事板 ID:“view2”。然后在Button的函数中我添加了这段代码:
@IBAction func newGamePressed(sender: AnyObject) {
let view2 = self.storyboard?.instantiateViewControllerWithIdentifier("view2") as
ViewController2
self.navigationController?.pushViewController(view2, animated: true)
}
但是,当我单击按钮时,实际上什么也没有发生!!!我做错了什么???
【问题讨论】:
-
按钮连接到我假设的 IB 动作函数 newGamePressed?
标签: ios xcode swift uiviewcontroller uinavigationcontroller