Iphone 如何在UIImagePickerController中禁用视频捕获

Iphone 如何在UIImagePickerController中禁用视频捕获,iphone,objective-c,ios,camera,Iphone,Objective C,Ios,Camera,我正在开发一个允许图像捕获但不允许视频捕获的应用程序,但我不知道如何从UIImagePickerView中删除照片/视频切换。这是我正在使用的代码,取自苹果的文档: UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera; // Displays a control that

我正在开发一个允许图像捕获但不允许视频捕获的应用程序,但我不知道如何从UIImagePickerView中删除照片/视频切换。这是我正在使用的代码,取自苹果的文档:

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];

我想保留除照片/视频开关以外的所有相机控制。谢谢

您只需将UIImagePickerController的mediaType属性设置为仅包含图像,您在其中使用的属性用于分配所有可用的媒体类型。您可以了解它,如果您不确定类型是什么,您可以始终将其输出到控制台,然后使用适当的数组设置该数组(仅允许图片)或删除此行:

cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeCamera];

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

啊,好的。我通读了这些文档,就像你说的那样,我将mediaType设置为这样,似乎可以工作:cameraUI.mediaTypes=[[[NSArray alloc]initWithObjects:(NSString*)kUTTypeImage,nil]autorelease];别忘了
#导入
别忘了
#导入
这确实是应该被接受的答案。但是kUTTypeImage不可用now@Gank要使用kUTTypeImage,您需要这样:
picker.mediaTypes=[kUTTypeImage作为字符串]
。您还必须导入
MobileCoreServices
。这里的答案:最好的答案…谢谢我被困了大约3个小时,这只是一行代码…上帝保佑你