ios11.0以上版本,table下拉刷新后留白回不去,上拉刷新一只跳不停的问题解决办法

网上搜了很多,但是很多说的不明确,作为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;

猜你喜欢

转载自blog.csdn.net/prettynacl/article/details/90923014