iOS tableView reloadData 后 cell 发生位移,出现跳动

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xjh093/article/details/87981827

默认值的问题

UITableViewAutomaticDimension.

@property (nonatomic) CGFloat estimatedRowHeight NS_AVAILABLE_IOS(7_0); // default is UITableViewAutomaticDimension, set to 0 to disable
@property (nonatomic) CGFloat estimatedSectionHeaderHeight NS_AVAILABLE_IOS(7_0); // default is UITableViewAutomaticDimension, set to 0 to disable
@property (nonatomic) CGFloat estimatedSectionFooterHeight NS_AVAILABLE_IOS(7_0); // default is UITableViewAutomaticDimension, set to 0 to disable

设置 tableView.estimatedRowHeight = 具体的接近 cell 高度的值


关于刷新的优化

1.先 reloadData,再endRefreshing

2.先 endRefreshing,再reloadData
更好一些

2 会先恢复原状,再次上拉才能看到新内容
1 则会直接看到新内容


通用设置

直接在AppDelegate 内设置

#ifdef __IPHONE_11_0
    if (@available(ios 11.0,*))
    {
        UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        UITableView.appearance.estimatedRowHeight = 0;
        UITableView.appearance.estimatedSectionFooterHeight = 0;
        UITableView.appearance.estimatedSectionHeaderHeight = 0;
    }
#endif

参考

https://blog.csdn.net/jennyhermes/article/details/79628952


在任何 view 内进行 Push、Present,就是这么简单!

https://github.com/xjh093/JHPP


猜你喜欢

转载自blog.csdn.net/xjh093/article/details/87981827