如何使用UIImagePickerController为iPhone选择和录制视频? [英] How do I pick and record video using UIImagePickerController for iPhone?

查看:127
本文介绍了如何使用UIImagePickerController为iPhone选择和录制视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从iPhone上选择一个视频,用于我在网上上传的应用程序。
我使用的是UIImagePickerController。

I want to pick a video from iPhone for my application for uploading on the Web. I am using the UIImagePickerController for it.

用于开启选择器

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
[self presentModalViewController:imagePicker animated:YES];

它打开照片库并仅显示电影类型内容。

我有以下问题:

It opens the photo library and only shows the movie type content.
Now I have the following questions:


  • 如果我选择视频,然后准备播放,然后当我点击

  • 由于我们在iphone中有单独的文件夹,那么我们如何打开视频文件夹?

如果我能够选择,那么如何获取视频详细信息,因为委托方法是

If I am able to choose then how do I get video detail as delegate method is

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {

,并且它具有(UIImage *)img 参数。如何获得视频?

and it has (UIImage *)img parameter. How do I get it as video?

推荐答案

您使用的是错误的委托方法。 iOS 3.0引入了 imagePickerController:didFinishPickingMediaWithInfo:来替换 imagePickerController:didFinishPickingImage:editingInfo:。这个新方法接收NSDictionary,其包含与所选择的图像/视频相关的多个键值对;在您的情况下,您需要检查 UIImagePickerControllerMediaURL 的值。

You're using the wrong delegate method. iOS 3.0 introduced imagePickerController:didFinishPickingMediaWithInfo: to replace imagePickerController:didFinishPickingImage:editingInfo:. This new method receives an NSDictionary which contains a number of key-value pairs related to the chosen image/video; in your case, you'll want to check the value for UIImagePickerControllerMediaURL.

这篇关于如何使用UIImagePickerController为iPhone选择和录制视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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