首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将图片库图像存储在缓存或文件路径ios中

将图片库图像存储在缓存或文件路径ios中
EN

Stack Overflow用户
提问于 2013-01-29 18:43:48
回答 1查看 648关注 0票数 0

点击按钮我已经得到图像使用assestlibrary框架在ios中,并得到所有的图像,但点击按钮超过2-3次,应用程序变慢或崩溃,因为超过150张照片retrieved.Is有任何代码,我可以得到图像路径的图片库图像缓存,让应用程序顺利运行?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-29 19:26:02

我也有同样的问题。最后,我们将ALAssetUrl保存在一个数组中,而不是将图像存储在内存中。因此,每当您想要处理图像时,都可以使用其url将其从资源库中拉出。

代码语言:javascript
复制
-(void)storeAssetInArray:(ALAsset *)asset {
    _assetArray = [[NSMutableArray alloc] init];
    [_assetArray addObject:[asset valueForProperty:ALAssetPropertyURLs]];
}

-(void)getImageBackOut {
    [ALAssetsLibrary assetForURL:[_assetArray objectAtIndex:0] resultBlock:^(ALAsset *asset) {
        if (asset) {
            [self getTheImage:uploadImage Asset:asset];
        }
    } failureBlock:^(NSError *error){
        //Failed to get asset
    } ];
}

-(void)getTheImage:(UploadImage *)uploadImage Asset:(ALAsset *)asset {
    UIImage *image = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]];
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14581045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档