如何以编程方式切换屏幕?

时间:2015-09-30 11:28:30

标签: xcode swift2 xcode7

您如何以编程方式更改屏幕?我已经在我的项目main.storyboard中找到了播放按钮,并且所有内容都已定位,我将把故事板中的播放按钮连接到GameScene.swift。有什么办法可以帮助我吗?

2 个答案:

答案 0 :(得分:1)

您应该包含此代码按钮功能。

addToBackStack()

答案 1 :(得分:0)

您需要根据故事板和视图控制器名称更改以下代码。然后你可以使用它。

let yourStoryboardName = UIStoryboard(name: "YourStoryboardName", bundle: nil)
let yourViewControllerName = yourStoryboardName.instantiateViewControllerWithIdentifier("YourViewControllerName") as! YourViewControllerName
self.navigationController?.pushViewController(yourViewControllerName, animated: true)
相关问题