我有一个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;
}
问题是图片缩略图全部以低分辨率显示:
与原生相册相比:
如何才能以更好的分辨率显示图片?
PS:我正在使用"QBImagePicker" .
最佳答案
1.首先,确保你的QBImagePicker是最新的,版本在3.1.0以上 2.其次,你可以尝试手动修改targetSize的值,如下图:
// 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/