如何移动到多个视图控制器?

时间:2014-06-03 19:46:36

标签: uiviewcontroller swift

我希望以编程方式使用Apple的新Swift语言从viewController移动到另一个。我已经用Google搜索并阅读了文档,我看到了如何使用单个ViewController。有没有人有关于如何在视图控制器之间切换的示例或文档?

1 个答案:

答案 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);