我正在使用以下代码在iPhone上启动静态相机。
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
我想知道如何才能启动摄像机,而不是静态摄像机。我需要this view,而右下角没有开关。
有什么想法吗?
答案 0 :(得分:8)
您必须添加这两行才能在摄像机模式下启动。
picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
您也可以将其限制为视频模式并仅通过启用相应的媒体类型来隐藏切换。这样做只允许视频模式,
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
但是,您需要为MobileCoreServices.framework
添加#import <MobileCoreServices/MobileCoreServices.h>
。
答案 1 :(得分:2)
尝试添加
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;