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

slo*_*ker 5 uiviewcontroller swift

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

67c*_*ies 5

在类文档中有很多方法可以做到这一点UIViewController.

示例1 以下是使用该-presentViewConroller:方法的示例(假设此代码是在UIViewController子类中编写的):

var secondViewController = UIViewController() //create your second view controller. 
self.presentViewController(secondViewController, true, NULL)
Run Code Online (Sandbox Code Playgroud)

示例2 这是您如何呈现第二个UIViewController故事板(再次假设此代码是在UIViewController子类中编写的):

self.preformSegueWithIdentifier("segueIdentfier", self);
Run Code Online (Sandbox Code Playgroud)