我有两个嵌入在 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 的第一个选项卡的正确技术相关。
以下图片供引用:
最佳答案
如果您位于同一导航堆栈中,则可以使用展开转场。 但是,FeedView 位于不同的导航 Controller 上。
一种方法是使用以下方法让 TabbarController 切换回 FeedbackView(第一个选项卡):
tabBarController.selectedIndex = 0
关于ios - 从模态返回到第一个选项卡栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32061740/