簡體   English   中英

重新加載視圖時,Xcode Swift IOS Eureka LabelRow不更新標題

[英]Xcode Swift IOS Eureka LabelRow not updating title when view is reloaded

返回包含以下代碼的視圖時,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
        }

這是我“修復”它的操作:

override func viewDidAppear(_ animated: Bool)
{
    if let row = self.form.rowBy(tag: "Person")
    {
        row.title = currentPersonName
        row.reload()
    }
}

但這是最好的解決方案嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM