在 iOS 中打开包含视频和照片的图库 [英] open gallery with videos AND photos in iOS

查看:28
本文介绍了在 iOS 中打开包含视频和照片的图库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was using the UIImagePickerViewController, and i wanted to open the camera roll. But, in my app, i have a button to open my camera roll and another one to open my camera. When i take a picture or record a video, obviously i wanted to see those images in my camera roll. But, in my app, when i start to record a video, he doesn't show up in my camera roll's app.

这里有一些代码:

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

[cameraRoll setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];

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

此时我无法在相机胶卷的应用中看到我的视频.有人可以帮我吗?

At this time i can't see my videos in my camera roll's app. Could someone help me?

推荐答案

你可以这样做:

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];
}

在 PickerViewControllerObjectmediaTypes"的属性上设置您想要获取的文件类型,然后您就准备好了.

Sets the file types you want to get on the property of the PickerViewControllerObject "mediaTypes" and you're ready.

您可以找到 此处为文档类型.

问候,路易斯

这篇关于在 iOS 中打开包含视频和照片的图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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