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; }
相关文章
相关标签/搜索