ios - UICollectionView 单元格在滚动 UICollectionView 时会抖动

标签 ios objective-c iphone uicollectionviewcell sdwebimage

大家好,我是 IOS 开发的新手,我有一个 UICollection,我在其中使用 SDWebImageCache 加载图像。问题是我的 UICollectionview 单元格在快速滚动时感觉像抽搐或颤抖。 下面我发布了使用 SDWebImageCache 加载图像的代码

  [_homeCellImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",[dictionary objectForKey:@"user_image"],[QPCommonClass cropImageWithWidth:500 andHeight:500]]] placeholderImage:[UIImage imageNamed:@"defaultIcon"]];
    [_qpQuestionImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",[dictionary objectForKey:@"image"],[QPCommonClass cropImageWithWidth:1400 andHeight:1200]]] placeholderImage:[UIImage imageNamed:@"question"] options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL){
        [_qpHomeActivityIndicator setHidden:YES];
        [_qpHomeActivityIndicator stopAnimating];

    }];

其中 _homeCellImage 和 _qpQuestionImage 是 UIImageViews

最佳答案

  1. 确保在后台线程中加载图像。
  2. 加载图像后,请确保将其缓存。

现在通过cellForItem设置图片时,可以直接从缓存中加载图片,应该会流畅很多。

关于ios - UICollectionView 单元格在滚动 UICollectionView 时会抖动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35934069/

相关文章:

ios - objective-c : loop efficiently through particular range of elements within NSArray

iphone - 如何使用 iPhone 将照片上传到服务器?

iPhone AudioQueue - 读取传入的音频数据以确定 BPM

iphone - UINavigationController popViewController 正在弹出所有内容!

ios - 在 IOS 上向 NumberPad 添加下一步/完成按钮?

ios - 游戏中心(实时)仅显示本地分数

iphone - 按属性对 NSManagedObjects 的 NSSet 进行排序

ios - Xcode 中 Storyboard 模式下的页面是否有限制

iphone - performFetchWithCompletionHandler 只会被调用

ios - 从适用于 iOS 的 Google Maps SDK 中提取航向(罗盘)