1.先保存图片到本地,之后再获取名称
ALAssetsLibrary*assetsLibrary = [selfdefaultAssetsLibrary];
//// 保存到本地
[assetsLibrarywriteImageToSavedPhotosAlbum:[imageCGImage]orientation:(ALAssetOrientation)[imageimageOrientation]completionBlock:^(NSURL*assetURL,NSError*error){
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND,0),^{
[assetsLibraryassetForURL:assetURLresultBlock:^(ALAsset*asset){//这里的asset便是我们所需要的图像对应的ALAsset了
dispatch_async(dispatch_get_main_queue(),^{
//ALAssetRepresentation *representation = [asset defaultRepresentation];
//NSString *imageName = representation.filename;
//NSLog(@"imageName:%@", imageName);
[weakSelf.selectedAssets addObject:asset];
});
}failureBlock:^(NSError*error) {
//NSLog(@"%@", [error localizedDescription]);
ALERT_VIEW(@"图像保存在本地失败,请重新拍摄");
}];
});
}];
网友评论