美文网首页iOS常见问题记录
解决iOS 11 后改变cell高度刷新,cell跳动问题

解决iOS 11 后改变cell高度刷新,cell跳动问题

作者: 回南路宋三万 | 来源:发表于2019-12-11 10:43 被阅读0次

iOS11上的列表,刷新单个cell时,跳动幅度天大,原因:系统会给cell赋值一个预估值。

解决办法:

self.tableView.estimatedRowHeight = 400; 
// (设置一个合适的预估值,该预估值越接近实际cell高度越好,可以按照设计标注图cell高度设置) 

后续:后来测试代码原因,发现问题在于

                [self.tableView beginUpdates];
                [UIView performWithoutAnimation:^{
                    [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
                }];
                [self.tableView endUpdates];

去掉

 [self.tableView beginUpdates]; 
 [self.tableView endUpdates]; 

代码修改为

                [UIView performWithoutAnimation:^{
                    [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
                }];

即可

相关文章

网友评论

    本文标题:解决iOS 11 后改变cell高度刷新,cell跳动问题

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