[英]How can I push the next view controller on a navigation controller programmatically?
How can I push the next view controller on a navigation controller programmatically (without the need of a button)? 如何以编程方式(无需按钮)将下一个视图控制器按入导航控制器?
I know how to instantiate and present a new controller is the below 我知道如何实例化并呈现一个新的控制器如下
var next = self.storyboard?.instantiateViewControllerWithIdentifier("PlaceInfo") as! PlaceInfoController
self.presentViewController(next, animated: false, completion: nil)
but I want to push to the next view controller on the navigation controller. 但我想推送到导航控制器上的下一个视图控制器。 I tried the below self.navigationController?.pushViewController() but no success
我尝试了下面的self.navigationController?.pushViewController()但没有成功
var next = self.storyboard?.instantiateViewControllerWithIdentifier("PlaceInfo") as! PlaceInfoController
self.navigationController?.pushViewController(next, animated: true)
Have you tried using performSegueWithIdentifier
? 您是否尝试过使用
performSegueWithIdentifier
?
Learn more about this here: 在此处了解更多有关此的信息:
https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSSeguePerforming_Protocol/#//apple_ref/occ/intfm/NSSeguePerforming/performSegueWithIdentifier:sender : https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSSeguePerforming_Protocol/#//apple_ref/occ/intfm/NSSeguePerforming/performSegueWithIdentifier:sender :
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.