[英]The method selectRow(at:animated:scrollPosition:) doesn't call tableView(_:didSelectRowAt:)
[英]what is the different between isSelected method of tableviewcell and selectRow(at:animated:scrollPosition:) of tableview
當我想設置要選擇的單元格時,tableviewcell 的isSelected
方法和 tableview 的selectRow(at:animated:scrollPosition:)
有什么不同?
即cell.isSelected = true
vs tableview.selectRow(at:index, animated: false, scrollPosition: .none)
我發現大多數人使用后者,但我不知道為什么
一個單元格上的工作:意味着你有指向它的指針(主要是在 didSelectRow 中完成,例如在推送詳細視圖后取消選擇該行)。 另一個告訴表格視圖 select 單元格不必引用它。
選擇行(在:動畫:滾動位置:)
選擇由索引路徑標識的表視圖中的一行,可選擇將該行滾動到表視圖中的某個位置。
細胞.isSelected
isSelected
bool 影響單元格的外觀。 默認值為 false。
欲了解更多信息:
https://developer.apple.com/documentation/uikit/uitableviewcell/1623263-isselected https://developer.apple.com/documentation/uikit/uitableview/1614875-selectrow
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.