F.SO3 F.SO3 - 1 year ago 445
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
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 Source
    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
                        resultHandler:^void(UIImage *image, NSDictionary *info) {
                         //retrive all  images   
                     img = image;

Using PHImageManager to get the original image..

i hope this will help you...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download