天天看點

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;