Access Container View Controller from Parent iOS

后端 未结 11 2244
遥遥无期
遥遥无期 2020-11-28 18:13

in iOS6 I noticed the new Container View but am not quite sure how to access it\'s controller from the containing view.

Scenario:

11条回答
  •  误落风尘
    2020-11-28 18:19

    There is another way using Swift's switch statement on the type of the view controller :

    override func prepare(for segue: UIStoryboardSegue, sender: Any?)
    {
      switch segue.destination
      {
        case let aViewController as AViewController:
          self.aViewController = aViewController
        case let bViewController as BViewController:
          self.bViewController = bViewController
        default:
          return
      }
    }
    

提交回复
热议问题