代码之家  ›  专栏  ›  技术社区  ›  Ofri

无UI元素的Segue和Unwind Segue

  •  1
  • Ofri  · 技术社区  · 6 年前

    我有 UIViewController Segue 从A到B,单击B中的按钮,激活 unwindSegue 到A。

    到目前为止,我已经:

    @IBAction 2) 准备从A到B的序列的函数(在A中) 3) 调用 解卷 从B到A

    关于B的更多信息:

    标题:FilterView 情节提要ID:FilterView

    我试着创造一个片段:

    let segueToFilter = UIStoryboardSegue(identifier: "SegueToFilterView", source: self, destination: FilterViewController)
    

    我想这也许能满足我的需要。

    但我有个错误:

    Cannot convert value of type 'FilterViewController.Type' to expected argument type UIViewController
    

    如有帮助,将不胜感激:)

    1 回复  |  直到 6 年前
        1
  •  1
  •   Sweeper    6 年前

    真正地 真正地

    想法是这样的:

    • 创建VC实例
    • 通过设置一些属性将数据传递给它
    • 现在!
    • 在VC中,解散。

    present dismiss pushVC popVC 在导航控制器上。

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc = storyboard.instantiateViewController(withIdentifier: "FilterView") as FilterViewController
    vc.someProperty = someData // this is where you pass data
    vc.present(vc, animated: true, completion: nil)
    

    要传回数据,应该通过创建 FilterViewDelegate 第一个VC符合。在谷歌上查找更多信息。