返回到包含以下代码的视图时,LabelRow $ 0.title未被更新。
从更改全局变量的“推送”视图返回后,如何让LabelRow更新其标题?
form +++
Section("Current Person")
<<< LabelRow {
$0.title = currentPersonName // "currentPersonName" is a global variable
$0.tag = "Person"
}.cellUpdate { cell, _ in
cell.row.title = currentPersonName // set title to "currentPersonName"
print("cellUpdate shows \(currentPersonName)") // verify "currentPersonName" change
}.onCellSelection { _, _ in
// the following view controller sets "currentPersonName" to something new
let PersonPicker = PersonPicker()
self.navigationController?.pushViewController(PersonPicker, animated: false)
print("onCellSelection shows \(currentPersonName)") // verify "currentPersonName" change
}
答案 0 :(得分:0)
这是我做的“修复”操作:
override func viewDidAppear(_ animated: Bool)
{
if let row = self.form.rowBy(tag: "Person")
{
row.title = currentPersonName
row.reload()
}
}
但这是最好的解决方案吗?