简体   繁体   中英

ios navigation stack using storyboard segue

I have three view controllers:

messagesVC : doesn't have navigation controller a chatting room

viewControllerA : has navigation controller and directs to messagesVC

viewControllerB : has navigation controller and directs to messagesVC

All three view controllers have their own storyboard for organization purposes. Right now, I created a storyboard segue to move from vcA or vcB to messagesVC. I want to be able to put messagesVC on either vcA or vcB each time it's shown so that push view controller animation would work instead of presenting messagesVC modally. How would I achieve this??

In situation when you have segue in storyboard, choose the type of it 'show'. When your messageVC is in another storyboard, you should load it like this:

let storyboard = UIStoryboard(name: "VCAStoryboard", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("messageVC") as! MessageVC

Then push it like this:

nvaigationController!.pushViewController(vc, animated: true)

This will do the job.

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