ios - 高分辨率的 ALAsset 缩略图

标签 ios uiimage

我有一个collectionView,其中包含我的照片库中图片的缩略图:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    QBAssetCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AssetCell" forIndexPath:indexPath];
    cell.tag = indexPath.item;
    cell.showsOverlayViewWhenSelected = self.imagePickerController.allowsMultipleSelection;

   // Image
    ALAsset *asset = self.assets[indexPath.item];

    UIImage *image = [UIImage imageWithCGImage:[asset thumbnail]]; 
    cell.imageView.image = image;

    return cell;
}

问题是图片缩略图全部以低分辨率显示:

enter image description here

与原生相册相比:

enter image description here

如何才能以更好的分辨率显示图片?

PS:我正在使用"QBImagePicker" .

最佳答案

1.首先,确保你的QBImagePicker是最新的,版本在3.1.0以上 2.其次,你可以尝试手动修改targetSize的值,如下图:

enter image description here

// Image
PHAsset *asset = self.fetchResult[indexPath.item];
CGSize itemSize = [(UICollectionViewFlowLayout *)collectionView.collectionViewLayout itemSize];


CGSize targetSize = CGSizeScale(itemSize, self.traitCollection.displayScale);
NSLog(@"itemSize  h:%f,w:%f",itemSize.height,itemSize.width);
NSLog(@"targetSize  h:%f,w:%f",targetSize.height,targetSize.width);
targetSize = CGSizeMake(155.0, 155.0);

在 QBAssetsViewController.m -> -collectionView:cellForItemAtIndexPath:

关于ios - 高分辨率的 ALAsset 缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33723418/

相关文章:

ios - 始终在 NSURLSessionDataTask 中取回缓存数据

ios - Swift - 无法通过导航 Controller 中的自定义选项卡寻呼机传递数据

iphone - 绘制 UIImage 的选定区域

objective-c - Objective c UIImage 到 char* 转换返回空字符串

objective-c - 以 Retina 质量屏蔽 2 个 UIImages

xcode - 如何在每个 UITableViewCell 中分配不同的 UIImage?

ios - 将UIPasteboard内容粘贴到其他应用程序中

ios - 无法将 'is not null' 查询传递到服务器端

ios - 在 UIImageView IOS 中加载动画 gif

ios - 退出全屏后 MPMoviePlayerController 在 ios 中将缩放模式设置为 MPMovieScalingModeFill