Delegate using Container View in Swift

杀马特。学长 韩版系。学妹 提交于 2019-12-03 03:02:35

Looks like you defined the delegate, but have not set the delegate. This happens to me all the time.

Like @nwales said you haven't yet set the delegate. You should do set the delegate in prepareForSegue function on your first viewController (who contain the viewContainer)

First select the embed segue and set an identifier in the attributes inspector. Then in the parentViewController implement the func prepareForSegue like this:

 override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
    if(segue.identifier == "the identifier"){
        let embedVC = segue.destinationViewController as! ContainerViewController
        embedVC.dataViewDelegate = self
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!