我希望以编程方式使用Apple的新Swift语言从viewController移动到另一个。我已经用Google搜索并阅读了文档,我看到了如何使用单个ViewController。有没有人有关于如何在视图控制器之间切换的示例或文档?
答案 0 :(得分:5)
有很多方法可以在UIViewController
的课程文档中详细说明。
示例1
以下是使用-presentViewConroller:
方法的示例(假设此代码是在UIViewController
子类中编写的):
var secondViewController = UIViewController() //create your second view controller.
self.presentViewController(secondViewController, true, NULL)
示例2
这是您通过故事板呈现第二个UIViewController
的方式(再次假设此代码是在UIViewController
子类中编写的):
self.preformSegueWithIdentifier("segueIdentfier", self);