如何使用Swift将viewcontroller推送到导航堆栈?

时间:2015-02-22 21:32:37

标签: ios swift uiviewcontroller uinavigationcontroller

我在UIViewController之前设置了一个NavigationView控制器,我想以编程方式执行segue并将另一个Viewcontroller推送到导航堆栈。我怎样才能做到这一点?

class CreateEventViewController: UIViewController, CLLocationManagerDelegate {

    // Updated post with simple answer
    // If you have a Naviagation Controller already instantiated then all you have to do is perform segue and it will push it on the navigation stack   for you
    self.performSegueWithIdentifier("Event Creation Success", sender: nil)

}

编辑:

我的故事板的图片http://imgur.com/rgbNxI1

2 个答案:

答案 0 :(得分:0)

只有在您通过调用pushViewController设置了segue后,才会调用

performSegueWithIdentifier。放置pushViewController调用以响应初始化segue的任何操作。

答案 1 :(得分:0)

由于我的导航控制器已经实例化并且有一个导航堆栈,我所要做的就是performSegueWithIdentifier。无需pushViewController。

self.performSegueWithIdentifier("Event Creation Success", sender: nil)