需求:從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的機器上面,圖片的分辨率正常了,完美解決。測試