Loading UIImage from UIImagePickerControllerReferenceURL

吃可爱长大的小学妹 提交于 2019-12-04 06:13:43

Looks like you're on the right track, for saving the asset url.

Save
NSURL *picURL = [info objectForKey:@"UIImagePickerControllerReferenceURL"]
NSString *stringUrl = picURL.absoluteString;


Reload AssetURL
NSURL asssetURL = [NSURL URLWithString:stringUrl]

As for loading the asset later on, i'm going to base on the assumption you're not using arc. Which would explain why you're returnValue is nil.

Have you tried adding a retain to the result? for example:

    NSURL *referenceURL = [NSURL URLWithString:savedAssetURLString]
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    __block UIImage *returnValue = nil;
    [library assetForURL:referenceURL resultBlock:^(ALAsset *asset) {
        returnValue = [[UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]] retain]; //Retain Added
    } failureBlock:^(NSError *error) {
       // error handling
    }];
    [library release];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!