美文网首页
iOS 调用UITableView的reloadData表格偏移

iOS 调用UITableView的reloadData表格偏移

作者: 幻梦_ | 来源:发表于2018-01-04 10:16 被阅读0次

最近在写项目时遇到一些UITableView在iOS11上的坑:
第一个就是在调用reloadData的时候最下面的Cell会向上偏移再回到底部,
第二个就是从带有UITableView的VCpush到第二个界面,在pop回来时顶部会看到表格向下偏移在回到原位
解决方案:
在AppDelgate中加入这行代码

-(void)setUPAdapteriOS11{
    if (@available(iOS 11.0, *)) {
        [UITableView appearance].estimatedRowHeight = 0;
        [UITableView appearance].estimatedSectionFooterHeight = 0;
        [UITableView appearance].estimatedSectionHeaderHeight = 0;
        [UITableView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        [UIScrollView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
}

相关文章

网友评论

      本文标题:iOS 调用UITableView的reloadData表格偏移

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