[英]UITableview view reload animation issue
請在UITableview中觀看有關動畫問題的視頻。 當我從API獲取數據並刷新單元格時,它會比第一個單元格動畫問題擴大。
我將以下代碼用於重新加載單元。
self.tblSpDirectoryView.reloadRows(at: [IndexPath(row: 3, section: 0)], with: .none)
我也曾嘗試去愛解決方案。
self.tblSpDirectoryView.beginUpdates()
self.tblSpDirectoryView.reloadRows(at: [IndexPath(row: 3, section: 0)], with: .none)
self.tblSpDirectoryView.endUpdates()
在上述所有代碼之前,我僅使用了重載。
self.tblSpDirectoryView.reloadData()
這對我沒有幫助。 我已共享視頻文件以供理解, 請在這里找到視頻文件。
嘗試添加:
self.tableView.beginUpdates()
self.tableView.endUpdates()
您也可以嘗試計算所有像元高度。 並將它們傳遞給方法tableView(_:heightForRowAt:)
您的第一個代碼對於正在使用swift的reload部分是正確的3請嘗試以下代碼
let indexPath = IndexPath(item: row, section: 0) tableView.reloadRows(at: [indexPath], with: .fade)
動畫不能正確發生,如果表格視圖是靜態的,請在情節提要和tableview高度委托方法中同時檢查高度,如果您使用的是xib,則也要進行檢查。如果與情節提要和代碼不同,它將反映為這個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.