didFinishPickingMediaWithInfo未返回图片: [英] Image not returned by didFinishPickingMediaWithInfo:

查看:106
本文介绍了didFinishPickingMediaWithInfo未返回图片:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上试图从用户照片库(或相机)获取图像。
问题是,在iPad上时没有返回任何图像(兼容模式)。
以下是代码:

   - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *) info {

NSLog(@info:%@,info);
}

iPhone和iPhone模拟器日志(原始图片存在):

  info:{
UIImagePickerControllerMediaType =public.image;
UIImagePickerControllerOriginalImage =< UIImage:0x6b6b4e0>;
UIImagePickerControllerReferenceURL =assets-library://asset/asset.JPG?id = 39D9190B-064F-4C80-9B93-B4CA4FE01B22& ext = JPG;
}

iPad和iPad模拟器(兼容模式)日志:(没有原始图像!)

  info:{
UIImagePickerControllerMediaType =public.image;
UIImagePickerControllerReferenceURL =assets-library://asset/asset.JPG?id = 72AF462A-A8CE-4474-9535-B59A3154087D& ext = JPG;
}

有关为何发生这种情况的任何想法?我真的需要iPad图像。



我尝试从资产库中获取图像(我正确地做了吗?),但图像为空。

  NSURL * imageSource = [info objectForKey:UIImagePickerControllerReferenceURL]; 
UIImage * image1 = [[UIImage alloc] initWithContentsOfFile:[imageSource absoluteString]];

感谢您的任何建议。



编辑:我尝试在iPad 4.3模拟器中构建应用程序。这里检索图像没有问题 - 原始图像存在于信息字典中。在IOS 5中还有另一种方法吗?

解决方案

如果您确定iPad有图像,听起来像一个错误。



但是既然你可以获得参考网址,你可以使用ALAsset API来获取图像。



<抱歉,它应该是 ALAssets



供您参考,

  
- (void)assetForURL:(NSURL *)assetURL resultBlock:(ALAssetsLibraryAssetForURLResultBlock)resultBlock failureBlock:(ALAssetsLibraryAccessFailureBlock)failureBlock

这是一种 ALAssetsLibrary 的方法。



更多信息,请查看Apple的文件。


I'm basically trying to 'get' an image from the users photo library (or camera). The problem is, no image is returned when on iPad (Compatibility mode). Here is the code:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    NSLog(@"info: %@", info);
}

iPhone and iPhone simulator log (Original image exists):

info: {
UIImagePickerControllerMediaType = "public.image";
UIImagePickerControllerOriginalImage = "<UIImage: 0x6b6b4e0>";
UIImagePickerControllerReferenceURL = "assets-library://asset/asset.JPG?id=39D9190B-064F-4C80-9B93-B4CA4FE01B22&ext=JPG";
}

iPad and iPad simulator (Compatibility mode) log: (there is no Original Image!)

 info: {
UIImagePickerControllerMediaType = "public.image";
UIImagePickerControllerReferenceURL = "assets-library://asset/asset.JPG?id=72AF462A-A8CE-4474-9535-B59A3154087D&ext=JPG";
}

Any ideas on why this is happening? I really need the iPad image.

I tried getting the image from the assets library (am i doing this correctly?), but the image is null.

NSURL *imageSource = [info objectForKey:UIImagePickerControllerReferenceURL];
UIImage *image1 = [[UIImage alloc] initWithContentsOfFile:[imageSource absoluteString]];

Thank you for any suggestions.

EDIT: I tried building the application in the iPad 4.3 simulator. Here there are no problems in retrieving the image - the original image exists in the info dictionary. Is there another way to do it in IOS 5?

解决方案

If you're sure the iPad has the image, it sounds like a bug.

But since you can get the reference url, you can use ALAsset API to get the image.

sorry, it should be ALAssets.

For your reference,


- (void)assetForURL:(NSURL *)assetURL resultBlock:(ALAssetsLibraryAssetForURLResultBlock)resultBlock failureBlock:(ALAssetsLibraryAccessFailureBlock)failureBlock

it is a method of ALAssetsLibrary.

For more, you can check the document from Apple.

这篇关于didFinishPickingMediaWithInfo未返回图片:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆