问题描述
我在 NavigationController 中嵌入了两个 TabBarController 视图,一个视图以模态方式呈现,带有自己的 NavigationController:
I have two TabBarController views embedded in a NavigationController and one View presented modally with its own NavigationController:
FeedView (1) (TableViewController -> 包含在 TabBarController 中)
FeedView (1) (TableViewController -> Contained within TabBarController)
VenueView (2) (CollectionViewController -> 包含在 TabBarController 中)
VenueView (2) (CollectionViewController -> Contained within TabBarController)
SelectView (3) (ViewController -> 从 VenueView 模态呈现)
SelectView (3) (ViewController -> Modally presented from VenueView)
在 VenueView (2) 中,我有以下代码来调出 SelectView (3):
In VenueView (2), I have the following code to bring up SelectView (3):
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let selectNavigationController = self.storyboard?.instantiateViewControllerWithIdentifier("selectNavController") as! UINavigationController
let selectVC = selectNavigationController.topViewController as! SelectViewController
selectVC.currentVenue = venueItems[indexPath.row]
presentViewController(selectNavigationController, animated: true, completion: nil)
}
这允许我在没有 tabbarcontroller 的情况下调出 SelectView(3),但仍然有一个导航栏.我在 SelectView(3) 中有一个按钮,我想用它来保存对象的数据并转入 FeedView(1).
This allows me to bring up SelectView(3) without the tabbarcontroller, but still have a navbar. I have a button in SelectView(3) which I would like to use to persist an object's data and segue into FeedView(1).
我尝试了很多方法,但最接近成功的是转至 FeedView(1) 但添加更多 viewControllers(由导航栏中的按钮证明),而不是将其包含在 TabBarController 中.
I've tried many methods but the closest I've got to success was to segue to FeedView(1) but add more viewControllers (evidenced by buttons in navbar) and not have it contained within the TabBarController.
创建此转场的正确方法是什么?我知道如何保留数据,但我的问题与从模态视图切换到 BarTab 的第一个选项卡的正确技术更相关.
What is the correct way of creating this segue? I know how to persist the data but my question is more related to the proper technique of segueing from a modal View to the first tab of a BarTab.
下图供参考:
推荐答案
如果您保持在同一个导航堆栈中,您可以使用 unwind segue.但是,FeedView 位于不同的导航控制器上.
You could use an unwind segue if you stayed within the same navigation stack. However, FeedView is on a different navigation controller.
一种方法是使用以下方法让您的 TabbarController 切换回 FeedbackView(第一个选项卡):
One way to do it is to have your TabbarController switch back to FeedbackView (1st tab) using:
tabBarController.selectedIndex = 0
这篇关于从模态返回到第一个标签栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!