iPhone11上上拉加载不调用,iPhone6s上正常
描述bug 一次加载5条视频,上拉加载时,不调用footer block
必现/偶发? 必现
怎么样重现这个bug
https://user-images.githubusercontent.com/10040131/127792981-524ef022-5a71-42a1-b041-e1313f27ba25.mp4
运行环境
- iPhone11
- iOS14.4.2
- Xcode12.4 (12D4e)
代码
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width , [[UIScreen mainScreen] bounds].size.height - JX_SCREEN_BOTTOM)];
_tableView.showsVerticalScrollIndicator = NO;
@weakify(self)
self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
@strongify(self)
//进行数据刷新操作
self->page = 1;
[self checkShiPingData];
}];
self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
@strongify(self)
self->page ++;
[self checkShiPingData];
}];
_tableView.backgroundColor = [UIColor clearColor];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.rowHeight = [[UIScreen mainScreen] bounds].size.height - JX_SCREEN_BOTTOM;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
[self.tableView registerClass:AwemeListCell.class forCellReuseIdentifier:kAwemeListCell];
[self.view addSubview:self.tableView];
[self addObserver:self forKeyPath:@"currentIndex" options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew context:nil];
做一个可以复现完整的 Demo 传上来吧.
你的这个 observer 中可能做了对 contentOffset 的操作吧?
[self addObserver:self forKeyPath:@"currentIndex" options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew context:nil];
我也有同样的问题,但是我的是出现在iPhone XS Max,系统:13.7,的上面。而iPhone7上是正常的,系统:14.3
难道都没人弄个简单的 Demo 上来么..@@ @SUWW @songxing10000
公司项目之前是外包的,抽出来太麻烦了,没用tab 没用nav,坑啊
#pragma mark - KVO
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
//观察currentIndex变化
if ([keyPath isEqualToString:@"currentIndex"]) {
//设置用于标记当前视频是否播放的BOOL值为NO
_isCurPlayerPause = NO;
//获取当前显示的cell
AwemeListCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:_currentIndex inSection:0]];
[cell startDownloadHighPriorityTask];
__weak typeof (cell) wcell = cell;
__weak typeof (self) wself = self;
//判断当前cell的视频源是否已经准备播放
if(cell.isPlayerReady) {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isHomeVC"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"isDouyinList"]) {
//播放视频
[cell replay];
}else{
NSSLog(@"测试数据查看 === %d ==== %d",[[NSUserDefaults standardUserDefaults] boolForKey:@"isHomeVC"],[[NSUserDefaults standardUserDefaults] boolForKey:@"isDouyinList"]);
}
}else {
[[AVPlayerManager shareManager] pauseAll];
//当前cell的视频源还未准备好播放,则实现cell的OnPlayerReady Block 用于等待视频准备好后通知播放
cell.onPlayerReady = ^{
NSIndexPath *indexPath = [wself.tableView indexPathForCell:wcell];
if(!wself.isCurPlayerPause && indexPath && indexPath.row == wself.currentIndex) {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isHomeVC"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"isDouyinList"]) {
[wcell play];
}else{
NSSLog(@"测试数据查看 === %d ==== %d",[[NSUserDefaults standardUserDefaults] boolForKey:@"isHomeVC"],[[NSUserDefaults standardUserDefaults] boolForKey:@"isDouyinList"]);
}
}
};
}
} else {
return [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
搜索了下vc cell 中均没有contentOffset
请问这个问题解决了没
@atoutlan 来个 Demo?
又遇到了奇怪的现象,上拉加载1、2页正常,加载第3页时,一直显示转圈,block回调也不调用。 最后,的解决代码为
// 接口数据加入数组后,刷新table
[self.tableView reloadData];
// 有时候不会刷新了
MJRefreshFooter *footer = self.tableView.mj_footer;
footer.state = MJRefreshStateIdle;
if ([footer isKindOfClass:[MJRefreshBackGifFooter class]]) {
MJRefreshBackGifFooter *gifFooter = (MJRefreshBackGifFooter *)footer;
[gifFooter.gifView stopAnimating];
}
感觉这类不是auto的,都得自己手动重置state为MJRefreshStateIdle