简体   繁体   中英

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

 var next = self.storyboard?.instantiateViewControllerWithIdentifier("PlaceInfo") as! PlaceInfoController
 self.navigationController?.pushViewController(next, animated: true)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM