ios - 仅在 UIImagePickerController 中显示视频

标签 ios uiimagepickercontroller

我正在使用以下代码来呈现 UIImagePickerController。对于某些特定场景,我只需要视频。并使用以下代码。

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
imagePickerController.allowsEditing=NO;

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

[self presentViewController:imagePickerController animated:YES completion:nil];

但它在表格 View 中显示相机胶卷、我的照片流和视频。如果我打开任何文件夹,内容只是视频。我只想要视频我怎么能做到这一点。还有标题照片,我也想改变它到视频。

最佳答案

swift 3 更新:

let videoPicker = UIImagePickerController()  
videoPicker.delegate = self
videoPicker.sourceType = .photoLibrary
videoPicker.mediaTypes = [kUTTypeMovie as String]
self.present(videoPicker, animated: true, completion: nil)

导入 导入 MobileCoreServices 并在顶部添加委托(delegate) UIImagePickerControllerDelegateUINavigationControllerDelegate

呈现的模式将具有“照片”标题。 您可以这样更改它:

func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
        viewController.navigationItem.title = "Choose Video"
}

关于ios - 仅在 UIImagePickerController 中显示视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23112088/

相关文章:

ios - 如何裁剪具有 10 像素偏移的图像?

objective-c - 使用 NSDateFormatter 解析日期

ios - 压缩视频时 UIImagePickerController 取消按钮不起作用

当我使用 UIImagePickerController 允许编辑时 iOS 7 StatusBar 问题

ipad - uiimagepickercontroller 打开但不显示图像 ios 8

ios - 来自 xib 中自定义 TableCell 的 PresentViewController

ios - UIImagePickerController - 横向拍摄的照片在顶部创建黑条

iphone - 如何从 ABAddressBook 中快速获取组成员计数

iphone - 如何创建包装器以将 block 用于使用回调的类?

ios - 将 nsmutablearray 复制到另一个 viewcontroller 中的另一个 nsmutablearray 正在数组中显示空值