我正在寻找执行以下操作的最佳实践方法:
我在 NavigationController 中嵌入了两个 TabBarController View ,还有一个我不想作为选项卡包含但嵌入在 NavigationController 中的 View :
- 提要 View (TableViewController)
field View ( Collection View Controller )
选择 View ( View Controller )
在 VenueView (2) 中,我有以下代码来调出 SelectView (3):
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let selectVC: SelectViewController! = self.storyboard?.instantiateViewControllerWithIdentifier("selectVC") as! SelectViewController
selectVC.currentVenue = venueItems[indexPath.row]
presentViewController(selectVC, animated: true, completion: nil)
}
这个 segue 有效,但是 SelectView(3) 没有顶部的导航栏,尽管它嵌入在单独的 NavigationController 中。如果我将它连接到 IB 中的另一个 NavController,它将采用/成为 BarTabController 中的第三个选项卡。我不想这样。
我如何连接它以便有一个 NavBar(带有一个返回到任一 View 的后退按钮)但没有 Tab?
此外,SelectView(3) 上还有一个按钮。当点击此按钮时,我希望它转到 FeedView(1) - 同时保留一些数据,即“插入提要”。我应该为此使用什么样的segue?我尝试了很多组合并遇到了一些奇怪的错误,我发现 View 管理非常困惑。
下面的 Storyboard图片供引用 View 按从上到下的顺序(1-3):
最佳答案
为了做到这一点,您需要解决您的问题,您需要提供包含 SelectView
的导航 Controller ,但不像现在那样包含 SelectView
本身。
您应该为第三个导航 Controller 设置 Storyboard标识符并应用此更改:
let selectNavigationController = self.storyboard?.instantiateViewControllerWithIdentifier("selectNavigationController") as! UINavigationController
let selectVC = selectNavigationController.topViewController as! SelectViewController
selectVC.currentVenue = venueItems[indexPath.row]
presentViewController(selectNavigationController, animated: true, completion: nil)
关于ios - 正确的segue流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32017173/