美文网首页
UITableView刷新列表,刷新列表cell来回跳动的问题(

UITableView刷新列表,刷新列表cell来回跳动的问题(

作者: 小驴拉磨 | 来源:发表于2018-05-02 14:09 被阅读14次
Simulator Screen Shot - iPhone X - 2018-05-02 at 14.04.07.png

问题就是:点击点赞按钮后刷新列表,tableView来回跳动。而且打印tableView 的contentOffset是变化的。
具体原因的是因为在iOS 11Self-Sizing自动打开后,刷新列表后contentSize和contentOffset都可能发生改变导致列表来回跳动。
可以通过以下方式禁用:

self.estimatedRowHeight = 0;
self.estimatedSectionHeaderHeight = 0;
self.estimatedSectionFooterHeight = 0;

在iOS 10 以下 通过以下协议方法设置精准高度就可以了

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

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section NS_AVAILABLE_IOS(7_0);

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section NS_AVAILABLE_IOS(7_0);

相关文章

网友评论

      本文标题:UITableView刷新列表,刷新列表cell来回跳动的问题(

      本文链接:https://www.haomeiwen.com/subject/yaqcrftx.html