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

即可

你可能感兴趣的:(解决iOS 11 后改变cell高度刷新,cell跳动问题)