我正在使用以下代码来呈现 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) UIImagePickerControllerDelegate 和 UINavigationControllerDelegate
呈现的模式将具有“照片”标题。 您可以这样更改它:
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
viewController.navigationItem.title = "Choose Video"
}
关于ios - 仅在 UIImagePickerController 中显示视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23112088/