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

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];
                }];

即可

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。