在UIImagePickerController中,是否可以获取UIImagePickerControllerMediaURL的NSURL值? [英] In the UIImagePickerController, is it possible to get the NSURL value for UIImagePickerControllerMediaURL?

查看:1092
本文介绍了在UIImagePickerController中,是否可以获取UIImagePickerControllerMediaURL的NSURL值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户从选择器控制器中选择一个图像时,我正在调用该委托:

When the user selects an image from the picker controller, I'm calling the delegate:

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

字典信息中的密钥值 UIImagePickerControllerMediaURL NULL 。我在这里遗漏了什么吗?

in the dictionary info, the value for key UIImagePickerControllerMediaURL is NULL. Am I missing something here?

推荐答案

我知道这个问题非常古老,但我确实设法从最近的一段时间内徘徊谷歌搜索,所以我想我会认为实际上是你的问题的答案,其他答案似乎都错过了。

I know this question is horribly old, but I did manage to wander across it from a recent google search, so thought I'd throw in what I think is actually the answer to your question which the other answers seem to miss.

UIImagePickerControllerMediaURL你得到的是NULL因为它仅在选择器中为Movie(kUTTypeMovie)媒体类型返回。如果您在创建默认选择器时没有指定其他媒体类型,那么文档似乎意味着您将无法获得它:

You're getting NULL for UIImagePickerControllerMediaURL as it is only returned for the Movie (kUTTypeMovie) media type in a picker. If you're presenting a default picker without specifying additional media types after it's creation, then the docs seem to imply that you won't get it:


UIImagePickerControllerMediaURL - 指定电影的文件系统网址。

我可以确认它至少在我在iOS 6中做的快速测试中没有返回图像(不是电影)。

And I can confirm that it isn't returned at least in the quick test that I did in iOS 6 for images (not Movies).

要访问返回的图像,您实际上可以直接访问UIImagePickerControllerOriginalImage键下的UIImage对象(如果不允许编辑,则默认如果在选择器中允许编辑,则设置)或UIImagePickerControllerEditedImage。即使在选取器中进行了编辑,原始图像也始终可用。您可以像处理程序中的任何其他UIImage一样对待这些UIImage。

To access the image returned, you actually have direct access to a UIImage object under the keys of UIImagePickerControllerOriginalImage (if editing is not allowed, the default setting) or UIImagePickerControllerEditedImage if editing is allowed in the picker. The original image is always available, even if editing was done in the picker. You can treat these UIImage's just like you would any other UIImage in your program.

这篇关于在UIImagePickerController中,是否可以获取UIImagePickerControllerMediaURL的NSURL值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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