ios - 正确的segue流程

标签 ios xcode swift segue uistoryboardsegue

我正在寻找执行以下操作的最佳实践方法:

我在 NavigationController 中嵌入了两个 TabBarController View ,还有一个我不想作为选项卡包含但嵌入在 NavigationController 中的 View :

  1. 提要 View (TableViewController)
  2. field View ( Collection View Controller )

  3. 选择 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/

相关文章:

iphone - 如何在整个 iPhone 中创建自定义键盘

Swift 3 URL Session - 针对 URL 添加超时

swift - 如何在 INSendPaymentIntent (SiriKit) 中搜索特定联系人?

ios - 创建符合另一个协议(protocol)的协议(protocol)变量

ios - 如何计算可变换 ImageView 中的裁剪面积

ios - 使按钮从数组中读取字符串

ios - 如何重命名 iCloud 容器?

ios - 使用单个 ViewController 上的按钮打开不同的网页

iphone - CFNetwork WebCore 崩溃

ios - 即使清除所有文本字段后如何保留占位符