1

I have created the Collection View of all Thumbnail image from Photos for doing this I have written code below:

    var photoAssets: PHFetchResult<PHAsset> = PHFetchResult()

    let allPhotosOptions = PHFetchOptions()
    allPhotosOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]

    let allPhotosResult = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: allPhotosOptions)

    photoAssets = allPhotosResult

Now I have PhotoAssets of Array for fetching the thumbnail image for every single PHAsset I have written code :

    let manager = PHImageManager.default()
    let requestOptions = PHImageRequestOptions()
    public var thumbnailSize = CGSize(width: 100, height: 100)
    requestOptions.isSynchronous = true
    requestOptions.isNetworkAccessAllowed = true
    requestOptions.deliveryMode = .highQualityFormat
    requestOptions.resizeMode = .exact

    manager.requestImage(for: selectedAsset, targetSize: self.thumbnailSize, contentMode: PHImageContentMode.aspectFill, options: requestOptions) {
        image, info in
        // here I am getting the thumbnail image this code is running fine.
    }

When I select any thumbnail image from the UICollection view I get the index and get the PHAsset from the photoAssets array. Now for creating the full size image for this PHAsset I written code :

    let manager = PHImageManager.default()
    let requestOptions = PHImageRequestOptions()
    public var thumbnailSize = CGSize(width: 100, height: 100)
    requestOptions.isSynchronous = true
    requestOptions.isNetworkAccessAllowed = true
    requestOptions.deliveryMode = .highQualityFormat
    requestOptions.resizeMode = .exact
    manager.requestImage(for: selectedAsset, targetSize: PHImageManagerMaximumSize, contentMode: PHImageContentMode.aspectFill, options: requestOptions) {
        image, info in
        //completion(image, info as AnyObject)
        //here i'll get the full size image for requested PHasset 
   }

My problem is while getting the full size image for non iCloud enabled device the I am getting the image, but for those devices which is iCould enabled, i am getting image = nil and Creating an image format with an unknown type is an error

1 Answer 1

0

Creating an image format with an unknown type is an error

It's a bug in xcode , if picker could select and return images properly that means everything is okay , just ignore it .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.