点击按钮我已经得到图像使用assestlibrary框架在ios中,并得到所有的图像,但点击按钮超过2-3次,应用程序变慢或崩溃,因为超过150张照片retrieved.Is有任何代码,我可以得到图像路径的图片库图像缓存,让应用程序顺利运行?
发布于 2013-01-29 19:26:02
我也有同样的问题。最后,我们将ALAssetUrl保存在一个数组中,而不是将图像存储在内存中。因此,每当您想要处理图像时,都可以使用其url将其从资源库中拉出。
-(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]];
}https://stackoverflow.com/questions/14581045
复制相似问题