简体   繁体   English

如何使用UIImagePickerController类仅允许iPhone 3GS的录像机显示

[英]How to allow only the video recorder of iPhone 3GS to show up using UIImagePickerController class

Using UIImagePicker class I can select the UIImagePickerControllerSource as UIImagePickerControllerSourceTypeCamera. 使用UIImagePicker类,我可以选择UIImagePickerControllerSource作为UIImagePickerControllerSourceTypeCamera。 This would show up both the options, camera as well as video recoreder. 这将同时显示选项,摄像头和视频记录器。

I want only the video recording option to be available to the user. 我只希望用户可以使用视频录制选项。 And as soon as user opens it starts recording without the need to tap record button. 一旦用户打开,它便开始记录而无需点击记录按钮。

Anyone who knows how is it possible? 谁知道这怎么可能?

Thanks 谢谢

在UIImagePickerController上设置mediaTypes属性。

in your .h file 在您的.h文件中

#define MAX_VIDEO_DURATION 10
@interface VideoCaptureVC_iPhone : UIViewController
<UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
    IBOutlet UIImageView *imageView;
    UIImagePickerController *picker;
}

in your .m file 在您的.m文件中

- (void)viewDidLoad
{
 // Create UIImagePickerController
    picker = [[UIImagePickerController alloc] init];
    picker.videoQuality = UIImagePickerControllerQualityTypeMedium;
    picker.mediaTypes = [NSArray arrayWithObject:(NSString*)kUTTypeMovie];
    picker.videoMaximumDuration = MAX_VIDEO_DURATION;

    // Set the source type to the camera
    [picker setSourceType:UIImagePickerControllerSourceTypeCamera];

    // Set ourself as delegate
    [picker setDelegate:self];

    // Always check to see if there is a front facing camera before forcing one on the picker
    if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]){
        [picker setCameraDevice:UIImagePickerControllerCameraDeviceFront];
    }
    [picker setShowsCameraControls:NO];
[picker takePicture]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM