Keep uitableview static when inserting rows at the top

后端 未结 18 2094
名媛妹妹
名媛妹妹 2020-11-29 16:12

I have a tableView that I\'m inserting rows into at the top.

Whilst I\'m doing this I want the current view to stay completely still, so the rows only appear if you

18条回答
  •  情话喂你
    2020-11-29 16:41

    Just a heads up it does not seem possible to do this if you return estimated heights for the tableview.

       - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath ;
    

    If you implement this method and return a rough height your tableview will jump about when reloading as it appears to use these heights when setting the offsets.

    To get it working use one of the above answers (I went with @Mayank Yadav answer), don't implement the estimatedHeight method and cache the cell heights (remembering to adjust the cache when you insert additional cells at the top).

提交回复
热议问题