iOS11 Tableview顶部空白和Section Header留白问题

iOS11上废除了automaticallyAdjustsScrollViewInsets这个方法,所以造成iOS11机型顶端留白问题

解决方法:

if (@available(iOS 11.0, *)) {
self.tableview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else {
self.automaticallyAdjustsScrollViewInsets = NO;
}

iOS11上对滚动视图加入了self-sizeing,默认如果不去实现viewForHeaderInSection就不会调用heightForHeaderInSection

如果不实现上述方法,需要关闭自动估计高度

self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;

猜你喜欢

转载自blog.csdn.net/a136447572/article/details/79307665