封裝了一個tableView,添加了MJRefresh麻敌,然后就發(fā)現上拉加載無限加載栅炒,endRefreshing根本不管用...
一、先說解決辦法庸论,三行代碼:
你封裝的tableView里面添加
self.estimatedRowHeight = 0;
self.estimatedSectionHeaderHeight = 0;
self.estimatedSectionFooterHeight = 0;
即可职辅。
如果上面三行不行棒呛,那么再來幾行聂示。。簇秒。
(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0.01;
}(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return nil;
}(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.01;
}(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return nil;
}
Apple的建議一直是heightForFooterInSection和viewForFooterInSection要成對出現鱼喉,之前的代碼也因為不規(guī)范地只寫了heightForFooterInSection,導致了iOS11會造成tableview下一些UI展示偏移趋观。就像添加通知和移除通知一樣扛禽,有些API還是規(guī)范去實現比較好。
二皱坛、原因
iOS11更新以后编曼,估計是為了適配iPhone X的頭簾,把視圖的安全區(qū)域給改變了剩辟,具體的原理和適配方案請參考:
http://www.reibang.com/p/efbc8619d56b掐场。