找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 176|回复: 0

UICollectionView reloadData Cell 图片闪烁一下

[复制链接]

310

主题

0

回帖

956

积分

管理员

积分
956
发表于 2023-12-4 12:20:15 | 显示全部楼层 |阅读模式

刷新当然会闪。。
@kitalphaj tableView 就不闪诶。。
这……
要给 Placeholder 不然肯定会闪的, 要么你就用 sdwebimage
你是 reload 了特定的 indexPath 吗
同求解答:之前也遇到过一样的问题,用的 sdwebimage ,设了 placeholder , reload 后有时会闪有时不会。
prepare for reused 函数不要清图片,如果取图片需要很长时间 用个默认图顶着,如果图片设置后会触发自动布局也会引起
就是因为设置了 placeholder 才会闪
@paradoxs 用了 sdwebimage 还是闪、、
@cielpy 不啊 reload 全部哇
@dingsoung 请教一下 prepare for reused 是啥方法
@tutuge 没设 placeholder 有时候闪有时候不闪 咋回事
@niselover 丢上来看看
@paradoxs Photo *photo = self.allPhotos[indexPath.item]; OneAlbumCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];cell.imageView.image = nil; cell.isEditing = collectionView.allowsMultipleSelection;[cell.imageView sd_setImageWithURL:[NSURL URLWithString:photo.thumImageUrl]];
不想让他闪可以指定 reload 的 index ,也就是不管不刷新同时在想办法关闭动画,这种老问题 so 上有很多答案比如,给个参考:```swift CATransaction.begin() CATransaction.setDisableActions(true) // update or reload here CATransaction.commit()```
不全部刷新 打错了
@yongSir 感谢回复 试过了 不顶事 有时候还是闪。。
@niselover - (void)prepareForReuse {} 把 cell API 好好看看吧
cell.imageView.image=nil 去掉试下
```// 去掉 reloadData 时的动画 [UIView performWithoutAnimation:^{ [weakSelf.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]]; }];```之前写关于 UICollectionView 的 demo 的时候确实有遇到这种情况,我是这么解决的:[点这里]( https://github.com/kobe1941/HFRefresh/blob/master/HFRefresh/HFCollectionViewController.m)
可以不用 collectionView 的 reload ,把要刷新的 cell 通过 indexPath 取出来,然后直接对 cell 做操作。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|鲜于璜碑

GMT+8, 2024-9-8 11:57 , Processed in 0.092369 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表