【问题标题】:Container View controller variables are set to default when calling notification调用通知时容器视图控制器变量设置为默认值
【发布时间】:2018-05-18 17:21:22
【问题描述】:

我有一个包含 tableview 的容器视图控制器。在父视图控制器中,我使用下面的代码访问容器视图以设置一些变量并发送通知以重新加载表视图。但是当容器视图收到来自父级的通知时,它会将所有变量设置为默认值,并且不会将任何内容加载到表中:

在父视图控制器中:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let containerVC= storyboard.instantiateViewController(withIdentifier:"detailContainerVC") as! ContainerViewController

//   self.navigationController?.pushViewController(containerVC,
//                                           animated: false)

containerVC.section1RowCount = self.basicDataCount
containerVC.section2RowCount = self.checkDataCount
containerVC.GroupDetail = self.GroupDetail
containerVC.price = self.price
//containerVC.detailTable.reloadData()
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "fillDataDetail"), object: nil)

那么如何在父视图控制器中设置这个容器视图变量呢?

【问题讨论】:

    标签: ios swift xcode uicontainerview


    【解决方案1】:

    我通过在通知中使用 userInfo 发送参数来解决我的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-01
      • 2015-11-24
      • 2013-02-04
      • 1970-01-01
      • 1970-01-01
      • 2014-01-10
      相关资源
      最近更新 更多