快速复杂导航

问题描述 投票:-1回答:1

我在TabBarController下有5个ViewController。其中一个ViewController拥有一个UICollectionView。

单击UICollectionview内的UICollectionViewCell会对单独的ViewController(SubView1)进行选择-即不在TabBarController下。

SubView 1将托管内容,并允许用户更深入地了解SubView2。我目前正在UICollectionView上调用self.performSegue(withIdentifier:"segueToSubView1", selder: self),以演示文稿的形式跳转到SubView1:模态。

现在为了跳转到SubView2而在SubView1中执行相同的操作将触发另一个模式。感觉像在UICollectionView顶部有2个模态感觉不对。

已经尝试过:1)将SubView1嵌入导航控制器中,这似乎无法与TabBarcontroller一起使用2)全屏显示SubView1模态,并通过手动创建的后退按钮触发,单独返回到UICollectionView。但是,这确实破坏了UICollectionView上的TabBar,并且从头开始重新加载UICollectionView,而不是真正地向后导航。

有更好的方法吗?

swift uicollectionview uitabbarcontroller
1个回答
0
投票

您应该将视图控制器嵌入导航控制器中,然后将其嵌入到UITabBarController中。例如,下面是图像:

enter image description here

[而且,这更多是个人观点,我讨厌performSegue。它们使情节提要板看起来很凌乱。我更喜欢以编程方式进行。

let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "YourSubView1VCStoryboardID") 
        vc.hidesBottomBarWhenPushed = true // if you want to hide bottom tab bar. remove this line if you dont want to, or make it false
        self.navigationController?.pushViewController(vc, animated: true)
© www.soinside.com 2019 - 2024. All rights reserved.