[英]How to disable video capture in UIImagePickerController
I'm working on an app that allows image capture, but not video capture, but I can't figure out how to remove the photo/video toggle from a UIImagePickerView.我正在开发一个允许图像捕获但不允许视频捕获的应用程序,但我不知道如何从 UIImagePickerView 中删除照片/视频切换。 This is the code I'm working with, taken from Apple's documentation:这是我正在使用的代码,取自 Apple 的文档:
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
// Displays a control that allows the user to choose picture or
// movie capture, if both are available:
cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeCamera];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
cameraUI.allowsEditing = NO;
cameraUI.delegate = self;
[self presentModalViewController:cameraUI animated:YES];
I'd like to keep all the camera controls EXCEPT the photo/video switch.我想保留所有相机控件,除了照片/视频开关。 Thanks!谢谢!
Or remove this line:或删除此行:
cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeCamera];
The default value for cameraUI.mediaTypes is "kUTTypeImage". cameraUI.mediaTypes 的默认值为“kUTTypeImage”。 See the documentation .请参阅文档。
You just have to set the mediaType property of UIImagePickerController to only contain images, the one you are using there is used to assign all available media types..you can read about it here , if you arent sure what the types are you can always output them to console and then just set that array with the appropriate one (to allow only pictures)您只需将 UIImagePickerController 的 mediaType 属性设置为仅包含图像,您使用的那个用于分配所有可用的媒体类型。如果您不确定类型是什么,您可以在这里阅读他们进行控制台,然后使用适当的数组设置该数组(只允许图片)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.