解决iOS 11 后改变cell高度刷新,cell跳动问题
2019-12-11 本文已影响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];
}];
即可