[英]reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling
[英]reloadData of UITableView with Dynamic cell heights unwanted scroll
我試圖解決這個問題將近兩天! 而且我還沒有找到任何解決方案。
我有一個使用動態代碼的動態單元格高度的表格視圖
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 300.0
對於我的tableView,我正在使用無限滾動庫來加載更多具有動態高度的數據。
在某些情況下,我會用更新的數據重新加載我的表視圖! 當我調用reloadData()時,tableview會向上或向下滾動。 修正估計的 Rowheight應該高至少550.0
tableView.estimatedRowHeight = 550.0
解決此問題后,調用self.tableView.finishInfiniteScroll()時,infinitscroll出現另一個問題,tableView向上滾動(跳躍)
self.tableView.beginUpdates()
self.tableView.insertRowsAtIndexPaths(indxesPath, withRowAnimation: UITableViewRowAnimation.Fade)
self.tableView.endUpdates()
self.tableView.finishInfiniteScroll()
我正在使用AutoLayout ! 我正在iOS 9.1上進行測試
試試這個,不要在任何地方給桌子和單元格以高度
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
return UITableViewAutomaticDimension
}
func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
return 44.0
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.