UITableView scrollToRowAtIndexPath scrolls to wrong offset with estimatedRowHeight on iOS 7

后端 未结 9 1902
轮回少年
轮回少年 2021-02-12 12:46

I am using the estimatedRowHeight method from UITableView in iOS 7, which works perfectly for fast loading of a UITableView with 5000 rows of variable heights.

9条回答
  •  一个人的身影
    2021-02-12 13:33

    This solved my problem

    let oldContentSize = tableView.contentSize
    tableView.scrollToRow(at: indexPath, at: .top, animated: true)
    // Called again when tableView contentSize change
    if !tableView.contentSize.equalTo(oldContentSize) {
        tableView.scrollToRow(at: indexPath, at: .top, animated: true)
    }
    

提交回复
热议问题