F.SO3 F.SO3 - 5 months ago 162
Swift Question

PHImageManager fetch full size image

I have this function to fetch images from assets:

func fetchImage(asset: PhotoAsset, size: CGSize, resizeMode: ResizeMode = .Exact, completion: (result: UIImage?) -> Void) {
let photoAsset = asset as! PHAsset
var options: PHImageRequestOptions?
switch resizeMode {
case .Exact:
options = PHImageRequestOptions()
options?.resizeMode = .Exact
case .Default:
options = nil
}
manager.requestImageForAsset(
photoAsset,
targetSize: size,
contentMode: .AspectFill,
options: options
) { [weak self] result, _ in
completion(result: result)
}
}


but how can I denfine to fetch the original size image?

Thank you!

Answer
    PHImageManager *manager = [PHImageManager defaultManager];
    Albumimages = [NSMutableArray arrayWithCapacity:[assetArray count]];

    // assets contains PHAsset objects.
    UIImage *img;

    for (PHAsset *asset in assetArray) {
        // Do something with the asset

        [manager requestImageForAsset:asset
                           targetSize:PHImageManagerMaximumSize
                          contentMode:PHImageContentModeDefault
                              options:self.requestOptions
                        resultHandler:^void(UIImage *image, NSDictionary *info) {
                         //retrive all  images   
                     img = image;
                        }];
    }

Using PHImageManager to get the original image..

i hope this will help you...