用iOS中的视频和照片打开图库

问题描述:

我正在使用UIImagePickerViewController,并且我想打开相机胶卷。但是,在我的应用程序中,我有一个按钮来打开我的相机胶卷,另一个打开我的相机。当我拍摄照片或录制视频时,显然我想在相机胶卷中看到这些图像。但是,在我的应用程序中,当我开始录制视频时,他没有出现在我的相机胶卷应用程序中。用iOS中的视频和照片打开图库

这里的代码一点点:

UIImagePickerController *cameraRoll = [[UIImagePickerController alloc] init]; 

[cameraRoll setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; 

[cameraRoll setDelegate:self]; 
[self presentModalViewController:cameraRoll animated:YES]; 

在这个时候,我不能看到我的相机胶卷的应用我的影片。有人能帮助我吗?

你只可以这样做:

if([UIImagePickerController isSourceTypeAvailable: 
         UIImagePickerControllerSourceTypePhotoLibrary]) { 

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

    [self presentModalViewController:picker animated:YES]; 
} 

设置你想要得到的PickerViewControllerObject“mediaTypes”属性的文件类型,你准备好了。您可以找到docs types here

Regards, Luis