tableView上拉刷新上下跳动

上tableView部分代码:

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.sitcomListM.data.videos.count ? self.sitcomListM.data.videos.count+1 : 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
       if (!self.sitcomListM.data.videos.count) {
        
        JSBNoDataCell *noDataCell = [tableView dequeueReusableCellWithIdentifier:kNoDataCellReuseID forIndexPath:indexPath];
        noDataCell.errorMsg = @"微客堂列表为空,请稍后刷新";
        noDataCell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return noDataCell;
    }else {
        if ( !indexPath.row) { // 会员卡提示栏
            
            JSBVipPurchaseCell *cell = [tableView dequeueReusableCellWithIdentifier:kVipCellReuseID forIndexPath:indexPath];
            [cell configureWithDataModel:self.sitcomListM.data buttonClickBlock:nil ];
            return cell;
            
        }else{ //  视频列表
            
            JSBMoviePlayCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewCellReuseID forIndexPath:indexPath];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            //设置 cell 的数据
            JSBMoviePlaySitcomListDataVideosModel *videosM =  self.sitcomListM.data.videos[indexPath.row-1];
            cell.videosM = videosM;
            return cell;
        }
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
     if (!self.sitcomListM.data.videos.count) {
            return UITableViewAutomaticDimension;
        }
    return indexPath.row == 0 ?(!_type?36:186):186;
}

- (UITableView *)tableView {
    if (!_tableView) {
        // 底部 tableView
        _tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.estimatedRowHeight = 215;
        _tableView.separatorStyle = UITableViewCellSelectionStyleNone;
        
        [_tableView registerClass:[moviePlayCell class] forCellReuseIdentifier:kTableViewCellReuseID];
        [_tableView registerClass:[vipPurchaseCell class] forCellReuseIdentifier:kVipCellReuseID];
        [_tableView registerClass:[noDataCell class] forCellReuseIdentifier:kNoDataCellReuseID];
        
        _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewest)];
        _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadHistory)];
        
        _tableView.tableFooterView = [UIView new];
        _tableView.dataSource    = self;
        _tableView.delegate      = self;
    }
    return _tableView;
}
上拉刷新界面跳动bug.gif

界面在cell铺满整个屏幕是,上拉/下拉刷新 都没明显跳动;
界面中cell个数较少,不能铺满整个屏幕时,下拉刷新没有明显跳动,上拉刷新有明显跳动,并且会出现如下图的bug;

上拉刷新界面上下跳动bug.png

经过排除mjrefresh控件和项目中数据问题,最后bug问题锁定在tableview的预估行高(215)超出实际行高差距(36)太多导致出现上拉刷新跳动并出现相关bug;

         预估行高设置为50
        _tableView.estimatedRowHeight = 50;

该bug得以解决!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,597评论 4 61
  • 转载自:https://github.com/Tim9Liu9/TimLiu-iOS 目录 UI下拉刷新模糊效果A...
    袁俊亮技术博客阅读 14,121评论 9 105
  • 做人就像橐籥,“虚而不屈,动而愈出”。“道冲而用之或不盈”。就像九阳真经口诀“他强由他强,清风拂山冈。他横任他横,...
    中中地山谦阅读 2,790评论 1 6
  • 我是一名厨师,一名普通的厨师,一个名不见经传的西餐厨师。我的工作是每天和一堆冷冰冰的仪器打交道,用一个个看似没有生...
    Night_MarTin阅读 2,405评论 0 0
  • “床前明月光,疑是地上霜。举头望明月,低头思故乡。”这首太白先生的《静夜思》,不知是因为简单好记、通俗易懂,还是因...
    茗羁阅读 5,408评论 0 2

友情链接更多精彩内容