[英]Loading a photo taken from UIImagePickerController camera asynchronously
Initially, I thought I could use UIImagePickerControllerReferenceURL
to obtain the ALAsset
, then use that to generate an aspectRatioThumbnail
and load the ALAsset
asynchronously using GCD. 最初,我以为我可以使用UIImagePickerControllerReferenceURL
来获取ALAsset
,然后使用它生成一个aspectRatioThumbnail
并使用GCD异步加载ALAsset
。 However it appears that taking a photo from the UIImagePickerController
doesn't produce an ALAsset
as it's not stored in the photo library, only in memory. 但是,似乎从UIImagePickerController
拍摄照片不会产生ALAsset
因为它不存储在照片库中,而仅存储在内存中。
I'd still like to somehow produce an ALAsset
so I can access the aspectRatioThumbnail
and load it the same way I am with the UIImagePickterController
photo library. 我仍然想以某种方式生成ALAsset
以便可以访问aspectRatioThumbnail
并以与UIImagePickterController
照片库相同的方式加载它。 Is it possible to do this without saving the photo to the photo library? 是否可以在不将照片保存到照片库的情况下执行此操作?
Otherwise is there any other good ways to accomplish this outside of using ALAsset
? 否则,除了使用ALAsset
之外,还有其他什么好方法可以完成此ALAsset
吗?
Here is how to do it, doesn't really make sense to make a thumbnail because it'll prob cost too much in performance to do it: 这是操作方法,制作缩略图并没有多大意义,因为这样做可能会浪费太多性能:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissModalViewControllerAnimated:YES];
self.photoImageView.image = nil;
[self.activityIndicatorView startAnimating];
dispatch_async(dispatch_get_global_queue(0, 0), ^
{
UIImage *image = [[info objectForKey:@"UIImagePickerControllerOriginalImage"] retain];
dispatch_async(dispatch_get_main_queue(), ^
{
self.photoImageView.image = image;
[self.activityIndicatorView stopAnimating];
[image release];
});
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.