禁用重拍,播放和使用视频屏幕UIImagePickerController

时间:2014-05-02 11:54:03

标签: ios objective-c uiimagepickercontroller

我只想要一个屏幕: enter image description here 使用UIImagePickerController时,它使用两个屏幕。

但我不想要这个:

enter image description here

这可能吗?

2 个答案:

答案 0 :(得分:5)

@Fahri是正确AVFoundation更灵活但如果你想坚持UIImagePickerController你可以做的是通过将showsCameraControls属性设置为{来关闭相机控件{1}},然后展示您自己的视图和自定义方法。

将您的代码更改为:

<强> takeVideo

NO

<强> shootVideo

- (IBAction)takeVideo:(UIButton *)sender {

    UIToolbar *toolBar=[[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height-54, self.view.frame.size.width, 55)];

    toolBar.barStyle =  UIBarStyleBlackOpaque;
    NSArray *items=[NSArray arrayWithObjects:
                    [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel  target:self action:@selector(cancelVideo)],
                    [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace  target:nil action:nil],
                    [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera  target:self action:@selector(shootVideo)],
                    [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace  target:nil action:nil],
                    [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace  target:nil action:nil],
                    nil];
    [toolBar setItems:items];

    // create the overlay view
    UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-44)];
    overlayView.opaque=NO;
    overlayView.backgroundColor=[UIColor clearColor];

    // parent view for our overlay
    UIView *cameraView=[[UIView alloc] initWithFrame:self.view.bounds];
    [cameraView addSubview:overlayView];
    [cameraView addSubview:toolBar];

    picker = [[UIImagePickerController alloc] init];

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO){
        NSLog(@"Camera not available");
        return;
    }

    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
    picker.delegate = self;

    // hide the camera controls
    picker.showsCameraControls=NO;
    [picker setCameraOverlayView:cameraView];

    [self presentViewController:picker animated:YES completion:nil];

}

<强> cancelVideo

-(void) shootVideo {
    [picker startVideoCapture];
}

<强>截图

enter image description here

DOWNLOAD DEMO PROJECT

答案 1 :(得分:1)

如果您在发布问题之前已经检查了UIImagePickerController的文档,那么您可以使用AVFoundation库来构建您自己的相机控制器,以及您想要的任何控件和屏幕。祝你好运!