更新到ios11,然后使用x-code9運行項目,發現tableview的-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section方法不走,所以頁面也華麗麗的變成了一排的cell,通過查看文檔和資料,原來是ios11默認開啟self-sizing,把這個屬性關系即可,
具體代碼如下:
self.tableView.estimatedRowHeight = 0; self.tableView.estimatedSectionHeaderHeight = 0; self.tableView.estimatedSectionFooterHeight = 0;
把上面這幾句代碼加到初始化tableview的地方即可,其他的設置不用變!加完后,再運行,原來的設置就起效了!
更新到ios11的話,會發現UISearchBar消失不見了,這個時候需要做如下修改即可:
新建一個UIView類,實現如下方法即可:
-(CGSize)intrinsicContentSize { return UILayoutFittingExpandedSize; }
以上方法親測有效!