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

来源:互联网 发布:js前端开发群月报 编辑:程序博客网 时间:2024/06/06 23:58

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;

原创粉丝点击