如上图,视频播放列表有20个条目,当从第20条时继续上拉时,直到上拉完成才进行下一页的数据加载,产生了上图的跳动,极为影响用户体验。
解决方式:
翻看源码头文件,找到如下图所示属性
在刷新方法的代码中为该属性设置一个偏移值,当上拉达到偏移值时,便开始加载数据
- (void)addFooterPreloadWithAutomaticallyRefresh:(BOOL)automaticallyRefresh loadMoreBlock:(void(^)(NSInteger pageIndex))loadMoreBlock{
__weak typeof(self) weakSelf = self;
self.loadMoreBlock = loadMoreBlock;
MJRefreshAutoNormalFooter * footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
weakSelf.pageIndex += 1;
if (weakSelf.loadMoreBlock) {
weakSelf.loadMoreBlock(weakSelf.pageIndex);
}
[weakSelf endFooterRefresh];
}];
footer.automaticallyRefresh = automaticallyRefresh;
// 设置偏移量
footer.triggerAutomaticallyRefreshPercent = -70;
footer.onlyRefreshPerDrag = YES;
footer.stateLabel.font = [UIFont systemFontOfSize:13.0];
footer.stateLabel.textColor = [UIColor colorWithWhite:0.400 alpha:1.000];
[footer setTitle:@"加载中…" forState:MJRefreshStateRefreshing];
[footer setTitle:@"这是我的底线啦~" forState:MJRefreshStateNoMoreData];
self.mj_footer = footer;
}
结果展示(分页展示如丝般顺滑):