網上搜了很多,但是很多說的不明確,作爲xcode新手看不懂,後來結合很多結論,這裏記錄我的解決方案:
只需要在MJRefreshHeader.m中修改如下部分
- (void)placeSubviews
{
[super placeSubviews];
// 設置y值(當自己的高度發生改變了,肯定要重新調整Y值,所以放到placeSubviews方法中設置y值)
self.mj_y = - self.mj_h - self.ignoredScrollViewContentInsetTop;
if (@available(iOS 11.0, *)) {
self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
if ([self.scrollView isKindOfClass:[UITableView class]]) {
// iOS 11的tableView自動算高默認自動開啓,不想使用則要這樣關閉
UITableView *tableView = (UITableView *)self.scrollView;
tableView.estimatedRowHeight = 0;
tableView.estimatedSectionHeaderHeight = 0;
tableView.estimatedSectionFooterHeight = 0;
}
}
}
之前爲了解決上拉刷新跳動問題,在每個table初始化時設置了這幾行(也是網上找的方案),好用的,不過後來發現按上面修改了MJRefreshHeader.m以後,這幾行不加也可以了,免去了每個table修改一次的麻煩。 每個人手裏的代碼版本不同,所有找來的方案都只供參考。
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;