1.TableView
在iOS 11中默認啟用Self-Sizing 未使用AutoLayout的TableView中的高度會出現(xiàn)問題.
- Self-Sizing在iOS11下是默認開啟的,Headers, footers, and cells都默認開啟Self-Sizing,所有estimated 高度默認值從iOS11之前的 0 改變?yōu)閁ITableViewAutomaticDimension.
如果目前項目中沒有使用estimateRowHeight屬性,在iOS11的環(huán)境下就要注意了,因為開啟Self-Sizing之后,tableView是使用estimateRowHeight屬性的,這樣就會造成contentSize和contentOffset值的變化,如果是有動畫是觀察這兩個屬性的變化進行的,就會造成動畫的異常,因為在估算行高機制下,contentSize的值是一點點地變化更新的,所有cell顯示完后才是最終的contentSize值。
因為不會緩存正確的行高,tableView reloadData的時候,會重新計算contentSize,就有可能會引起contentOffset的變化。iOS11下不想使用Self-Sizing的話,可以通過以下方式關(guān)閉:
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
1.TableView 中,如果設(shè)置了tableview的tableFooterView
_mainTableView.tableFooterView = self.footerView;
那么, 需要實現(xiàn)tableview的下面的幾個代理方法,向上面那樣把 estimatedRowHeight , estimatedSectionHeaderHeight, estimatedSectionFooterHeight 都置為0,是不好使的,第一個cell還是會下移
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.01;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.01;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
return nil;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
return nil;
}