загрузка фото из icloud
У меня есть collectionView в которой загружены фотографии через PHAsset
инициализация PHAsset
fileprivate var fetchResult: PHFetchResult<PHAsset>!
fileprivate let imageManager = PHCachingImageManager()
fileprivate var fetchOptions: PHFetchOptions?
func viewDidLoad() {
fetchOptions = PHFetchOptions()
fetchOptions!.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
fetchResult = PHAsset.fetchAssets(with: .image, options: fetchOptions)
imageManager.allowsCachingHighQualityImages = true
view?.refreshView()
}
и конфигурация ячейки:
func configure(cell: PhotoCollectionViewCell, forRow row: Int) {
let asset = fetchResult.object(at: row)
let requestOptions = PHImageRequestOptions()
requestOptions.isNetworkAccessAllowed = true
requestOptions.deliveryMode = .highQualityFormat // Quality of images
imageManager.requestImage(for: asset, targetSize: CGSize(width: 400, height: 400), contentMode: .default, options: requestOptions, resultHandler: { image, info in
// The cell may have been recycled by the time this handler gets called;
// set the cell's thumbnail image only if it's still showing the same asset.
cell.photoImage.image = image
})
}
и при выборе ячейки пытаюсь получить URL фотографии
func didSelect(row: Int) {
fetchResult.object(at: row)
.requestContentEditingInput(with: PHContentEditingInputRequestOptions()) { [weak self] (editingInput, info) in
let input = editingInput
//some code for image cropping
}
}
и периодически я получаю editingInput = nil, как я понимаю это происходит тогда, когда фотография загружена в iCloud
Как мне загрузить полноразмерный оригинал фотографии с iCloud или получить url для фотки?