Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 禁用重新拍摄、播放和使用视频屏幕UIImagePickerController_Ios_Objective C_Uiimagepickercontroller - Fatal编程技术网

Ios 禁用重新拍摄、播放和使用视频屏幕UIImagePickerController

Ios 禁用重新拍摄、播放和使用视频屏幕UIImagePickerController,ios,objective-c,uiimagepickercontroller,Ios,Objective C,Uiimagepickercontroller,我只想听到一声尖叫: 使用UIImagePickerController时,它使用两个屏幕 但我不想要这个: 这是可能的吗?如果您在发布问题之前已经检查了UIImagePickerController的文档,那么您可以使用AVFoundation库构建您自己的相机控制器,以及您想要的任何控件和屏幕。祝你好运 @Fahri是正确的AVFoundation更灵活,但是如果您想坚持使用UIImagePickerController,您可以通过将showsCameraControls属性设置为NO来关

我只想听到一声尖叫: 使用
UIImagePickerController
时,它使用两个屏幕

但我不想要这个:


这是可能的吗?

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

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

将代码更改为:

拍摄视频

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

}
-(void) shootVideo {
    [picker startVideoCapture];
}
- (IBAction)cancelVideo {
    [self dismissViewControllerAnimated:YES completion:nil];
}
取消视频

- (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];
}
屏幕截图


对不起,我认为可能有一个简单的方法来完成这项任务。是的,对不起,我忘记了:)这可能是完成任务的更快的方法,@Maximilian.Hey@meda我对“picker”有问题,我需要在头文件中放什么对不起?@Maximilian你必须在类级别声明它,请看我的编辑我为您下载了一个演示项目您如何处理“FinishedPickingMedia”?