简体   繁体   English

使用情节提要segue的ios导航堆栈

[英]ios navigation stack using storyboard segue

I have three view controllers: 我有三个视图控制器:

messagesVC : doesn't have navigation controller a chatting room messagesVC :没有导航控制器的聊天室

viewControllerA : has navigation controller and directs to messagesVC viewControllerA :具有导航控制器并定向到messagesVC

viewControllerB : has navigation controller and directs to messagesVC viewControllerB :具有导航控制器并定向到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. 现在,我创建了一个情节提要segue,以从vcA或vcB移到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. 我希望每次显示时都可以将messageVC放在vcA或vcB上,这样推视图控制器动画就可以工作,而不是模态地显示messageVC。 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: 当您的messageVC在另一个情节提要中时,您应该像这样加载它:

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. 这样就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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