ios - 从模态返回到第一个选项卡栏

标签 ios xcode swift uitabbarcontroller uistoryboardsegue

我有两个嵌入在 NavigationController 中的 TabBarController View 和一个以其自己的 NavigationController 模态呈现的 View :

FeedView (1)(TableViewController -> 包含在 TabBarController 中)

VenueView (2)(CollectionViewController -> 包含在 TabBarController 内)

SelectView (3)(ViewController -> 从 VenueView 模态呈现)

在 VenueView (2) 中,我有以下代码来调出 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)。

我尝试了很多方法,但最接近成功的方法是继续使用 FeedView(1) 但添加更多 viewController(通过导航栏中的按钮证明)并且不将其包含在 TabBarController 中。

创建这个segue的正确方法是什么?我知道如何保存数据,但我的问题更与从模态视图到 BarTab 的第一个选项卡的正确技术相关。

以下图片供引用:

enter image description here

最佳答案

如果您位于同一导航堆栈中,则可以使用展开转场。 但是,FeedView 位于不同的导航 Controller 上。

一种方法是使用以下方法让 TabbarController 切换回 FeedbackView(第一个选项卡):

 tabBarController.selectedIndex = 0

关于ios - 从模态返回到第一个选项卡栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32061740/

相关文章:

ios - 如何从 Swift 中的另一个类重新加载 Collection View Cells

ios - iOS 7.1 中的 UISlider setMaximumTrackTintColor

ios - 为什么我的应用程序恢复后不返回到我的详细 View ?

ios - 从 iOS 错误路径上的 Documents 文件夹内的文件夹保存和获取图像

ios - SwiftUI:如何 "swipe delete"嵌套 ForEach 中的元素(分组)

iphone - 重新加载 RootView Controller 或重启 App

iphone - 如何在 HTML 文档中找到数字然后用作 NSString?

arrays - 使用下标扩展数组 (Swift)。 Xcode 6 beta 7 中的错误?

iOS:在屏幕上添加具有固定位置的 subview

ios - 如何使用字典构建以下复杂结构?