문제

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

But I don't want this one:

enter image description here

Is this possible?

도움이 되었습니까?

해결책

@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.

Change your code to:

takeVideo

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

}

shootVideo

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

cancelVideo

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

screenshot

enter image description here

DOWNLOAD DEMO PROJECT

다른 팁

If you have already checked the documentation of UIImagePickerController before posting your question, then you can use AVFoundation library to build your own camera controller, with any controls and screens you want. Good Luck!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top