简体   繁体   English

异步加载从UIImagePickerController相机拍摄的照片

[英]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.

相关问题 如何保存用UIImagePickerController相机拍摄的照片以稍后在应用程序中显示? - How can I save a photo taken with UIImagePickerController camera to be displayed later in the app? 如何检测照片库中的图像是由iPhone相机拍摄还是导入 - how to detect if image from photo library was taken by iPhone camera or imported 获取从相机/照片库拍摄的图像的名称 - Get the name of an image taken from camera/photo library 从iPhone中的相机拍摄时,将视频保存到照片库 - Saving videos to photo library when taken from camera in IPhone UIIMagePickerController +相机+全屏拍摄照片 - UIIMagePickerController + Camera + full screen capture photo UIImagePickerController相机不保存照片库中的照片 - UIImagePickerController Camera Not saving Photos in Photo Library 如何设置使用UIImagePickerController拍摄的照片进行查看/修改为自定义UIViewController? - How to set photo taken with UIImagePickerController to be viewed/modified into a custom UIViewController? iPhone 4相机UIImagePickerController中的UIImage HDR照片是否包含HDR信息? - Does the UIImage HDR photo from the iPhone 4 camera UIImagePickerController contain HDR information? iPhone 4相机拍摄的照片分辨率是多少? - what is resolution of photo taken by iPhone 4 camera? 在iPad或iPhone相机中拍摄的照片的DPI是多少? - What is DPIs of photo taken in iPad or iPhone camera?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM