0

使用 UIImagePicker 类我可以选择 UIImagePickerControllerSource 作为 UIImagePickerControllerSourceTypeCamera。这将显示两个选项,相机以及录像机。

我只希望用户可以使用视频录制选项。一旦用户打开它就开始录制,而无需点击录制按钮。

谁知道这怎么可能?

谢谢

4

2 回答 2

2

在 UIImagePickerController 上设置mediaTypes属性。

于 2009-08-07T13:01:29.593 回答
0

在你的 .h 文件中

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

在你的 .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]
}
于 2013-02-07T11:03:57.920 回答