我的DetailViewController
有一个container
视图。将出现的第一个容器视图是DetailChildViewController
。
DetailChildViewController
由一个集合视图组成,该视图将显示子视图的属性。但是,即使我在prepare(for segue :)函数中将数据分配给detailChildVC的属性,DetailChildViewController
中的属性变量仍为returns nil
。我该如何解决这个问题?
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Set the currentViewController to description child VC because that is the first one
// shown in the container view
if segue.identifier == "DetailChildSegue" {
let detailChildVC = DetailChildViewController()
// Set product of the childVC
let actionArray = [product?.action.keys.description] as? [String]
detailChildVC.properties = actionArray
}
// Set the currentVC
currentVC = segue.destination
}
答案 0 :(得分:0)
您指定新的DetailChildViewController()
而不是目的地
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "DetailChildSegue" {
let detailChildVC = segue.destination as! DetailChildViewController
let actionArray = [product?.action.keys.description] as? [String]
detailChildVC.properties = actionArray
}
// Set the currentVC
currentVC = segue.destination
}