ALAsset缩略图具有高分辨率

时间:2015-11-15 18:35:59

标签: ios uiimage

我在PhotoLibrary中有一个带有图片缩略图的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 个答案:

答案 0 :(得分:1)

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: