Xcode9 iOS 11 使用MJRefresh TableView出現異常。

Xcode 9 iOS 11 使用MJRefresh TableView出現異常。輸入圖片說明

使用MJRefresh 上拉加載的時候若是沒有更多數據, 數據刷新Tableview 而後 [self.tableView.mj_footer endRefreshing] 頭部留空現象. tableview已向下偏移 下拉動畫已隱約出現一小部分 下拉刷新動畫 出現異常 以前版本並未出現這種問題。 查閱發現 iOS11棄用了automaticallyAdjustsScrollViewInsets屬性,新增contentInsetAdjustmentBehavior來替代它 UIScrollViewContentInsetAdjustmentBehavior 是一個枚舉類型,值有如下幾種: -automatic 和scrollableAxes同樣,scrollView會自動計算和適應頂部和底部的內邊距而且在scrollView 不可滾動時,也會設置內邊距. -scrollableAxes 自動計算內邊距. -never不計算內邊距 -always 根據safeAreaInsets 計算內邊距 方法一: if (@available(iOS 11.0, *)) { _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } 方法二: if (@available(iOS 11.0, *)) { self.tableView.estimatedRowHeight =0; self.tableView.estimatedSectionHeaderHeight =0; self.tableView.estimatedSectionFooterHeight =0; } 方法三:注意⚠️:這種問題未使用上面解決辦法而使用如下這種方法,只能解決留白問題,反而致使上拉刷新回彈問題動畫

  • (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ return nil; }
  • (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ return nil; }
相關文章
相關標籤/搜索