如何在 UIImagePickerController 中禁用视频捕获

发布于 2024-11-19 06:45:51 字数 760 浏览 1 评论 0原文

我正在开发一个允许图像捕获但不允许视频捕获的应用程序,但我不知道如何从 UIImagePickerView 中删除照片/视频切换。这是我正在使用的代码,取自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'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. This is the code I'm working with, taken from Apple's documentation:

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦境 2024-11-26 06:45:51

或者删除此行:

cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeCamera];

cameraUI.mediaTypes 的默认值为“kUTTypeImage”。请参阅文档

Or remove this line:

cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeCamera];

The default value for cameraUI.mediaTypes is "kUTTypeImage". See the documentation.

桃气十足 2024-11-26 06:45:51

您只需将 UIImagePickerController 的 mediaType 属性设置为仅包含图像,您在那里使用的属性用于分配所有可用的媒体类型..您可以阅读有关它的信息 这里,如果你不确定类型是什么,你可以随时输出他们到控制台,然后只需将该数组设置为适当的数组(仅允许图片)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文