2017-02-04 68 views
0

我想在回到tableview後重新加載行。Tableview在回來後重新加載行tableview

在第一次重新加載tableview我可以重新加載與下面的代碼和數據影響行。

let indexPath = IndexPath(row: 2, section: 0) 
     tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic) 

當我回到前面的視圖後退按鈕,然後再次打開相同的tableview我無法重新加載行。

代碼工作我可以看到當重載代碼調用cellForRowAt indexPath函數但數據沒有影響它。

任何人有什麼想法?

回答

0

嘗試在viewWillAppear函數中執行相同的代碼。類似於

override func viewWillAppear(_ animated: Bool) { 
     tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic) 
    } 

但是您需要傳回有關點擊哪個indexPath的信息。

相關問題