UITableView scrollToRowAtIndexPath scrolls to wrong offset with estimatedRowHeight on iOS 7

后端 未结 9 1858
轮回少年
轮回少年 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:34

    Unfortunately this issue is to be expected when using estimatedRowHeight in your code with such a low value. When you scrollToRowAtIndexPath it does not actively calculating the correct size as you go. The underlying cause is, if you scrolled from Section 1 to Section 2, it could feasibly calculate the correct position on the fly and the estimatedRowHeight of the cells if it was a relatively new device. Any older devices would be brought to their knees, and even any new ones would be as well if you had to process 5000 cells, for example.

    A maybe-solution to your problem could be to increase the estimatedRowHeight constant so the device doesn't have to do as much work.

提交回复
热议问题