需求:从iOS图库获取图片的路径,而后在UICollectionView中进行显示。数组
问题:获取图片的路径,而后先存放在一个数组里面,最后在CollevtionView的CellForItemAtIndexPath中调用获取图片的方法,在cell中进行图片的展现,通常状况下都是默认使用[asset thumbnial]来获取图片的,之前的版本也是这样用,可是最近发现,调用该方法返回的图片分辨率很是低,只有正常分辨率的一半,坑爹。怪不得用户投诉。查看了文档后才知道,原来apple从iOS9.0开始,弃用该方法了,本身懒,不想推翻原来的代码,使用补漏的方式来让图片恢复原来的分辨率:app
ALAsset *asset = self.picArray[self.picArray.count-indexPath.row]; #pragma mark if (iOS9) { cell.photoImageView.image = [UIImage imageWithCGImage:[asset aspectRatioThumbnail]]; [cell.photoImageView setContentMode:UIViewContentModeScaleAspectFill]; }else{ cell.photoImageView.image = [UIImage imageWithCGImage:[asset thumbnail]]; [cell.photoImageView setContentMode:UIViewContentModeScaleAspectFit]; }
测试后发现,在iOS9的机器上面,图片的分辨率正常了,完美解决。测试