2011-03-13 67 views
3

现在我想实现像从设备相册选择图像和视频,并将其上传到服务器上的应用程序..iphone imagepickerController采摘视频

在这里我可以能够在同时显示图像和视频使用表格视图uiimagepickercontoller但我只能能挑到的图像没有视频..

如何选择视频格式照片lib中使用的UIImagePickerController ....

UIImagePickerController *ipc = [[UIImagePickerController alloc] init]; 
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
ipc.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:ipc.sourceType];  
ipc.delegate = self; 
ipc.editing = NO; 
[self presentModalViewController:ipc animated:YES]; 

`

+0

你好我也是在那里创建最初我想从浏​​览视频photolibrary视频应用,我已经阅读文件和使用的文档提供的代码,但它不工作。它不允许我浏览video.Could请你帮或提供我一些code.thanks – Rocky 2011-05-10 06:19:37

回答

8

检查docs并选择您需要的类型。

myImagePickerController.mediaTypes = 
    [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil]; 
+1

谢谢最大,但在didFinishPickingImage我的问题ID返回类型为图像怎么改视频 – theDebugger 2011-03-13 10:48:33

+0

你使用UIImagePickerControllerMediaURL? – Max 2011-03-13 10:51:50

+0

没有不习惯u能告诉我该生根粉或任何类似的源代码就 – theDebugger 2011-03-13 10:53:36

0

它在iPhone和iPad上进行了验证和测试用于拾取视频。

@property (strong,nonatomic) UIPopoverController *popOver; 

property is set for iPad access。

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

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
{ 
    UIPopoverController *popController=[[UIPopoverController alloc] initWithContentViewController:videoPicker]; 
    [popController presentPopoverFromRect:CGRectMake(0, 600, 160, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
    self.popOver=popController; 
} 
else 
{ 
    [self presentViewController:videoPicker animated:YES completion:nil]; 
}