禁用重拍、播放和使用视频屏幕 UIImagePickerController [英] Disable the retake, play and use video screen UIImagePickerController

查看:24
本文介绍了禁用重拍、播放和使用视频屏幕 UIImagePickerController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想要一个屏幕:使用 UIImagePickerController 时,它使用两个屏幕.

I am just wanting one screeen: When using the UIImagePickerController it uses two screens.

但我不想要这个:

这可能吗?

推荐答案

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

@Fahri is right AVFoundation is more flexible but if you want to stick with UIImagePickerController what you could do is turn off the camera control by setting showsCameraControls property to NO, then present your own view and custom methods.

将您的代码更改为:

拍摄视频

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

}

拍摄视频

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

取消视频

- (IBAction)cancelVideo {
    [self dismissViewControllerAnimated:YES completion:nil];
}

截图

下载演示项目知识库>

这篇关于禁用重拍、播放和使用视频屏幕 UIImagePickerController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆