iOS 11上运行tableView向下偏移64pt或者20pt

1、在iOS 11上运行tableView向下偏移64pt或者20pt,因为iOS 11废弃了automaticallyAdjustsScrollViewInsets,而是给UIScrollView增加了contentInsetAdjustmentBehavior属性。避免这个坑的方法是要判断

1
2
3
4
5
if  (@available(iOS  11.0 , *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else  {
self.automaticallyAdjustsScrollViewInsets = NO;
}

2、tableView的sectionHeader、sectionFooter高度与设置不符,因为tableView的estimatedRowHeight、estimatedSectionHeaderHeight、 estimatedSectionFooterHeight三个高度估算属性由默认的0变成了UITableViewAutomaticDimension。最简单的方法就是直接设置为0。

猜你喜欢

转载自blog.csdn.net/lichuandev/article/details/80193116