如何在UIImagePickerController中禁用视频捕获

时间:2011-07-06 17:46:12

标签: iphone objective-c ios camera

我正在开发一个允许图像捕获但不是视频捕获的应用程序,但我无法弄清楚如何从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];

除了照片/视频开关之外,我还要保留所有相机控件。谢谢!

2 个答案:

答案 0 :(得分:31)

或删除此行:

cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeCamera];

cameraUI.mediaTypes的默认值是“kUTTypeImage”。请参阅documentation

答案 1 :(得分:16)

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