0
votes

So I'm trying to force the user to record video in landscape mode with UIImagePickerController.

Thought a good way was to switch the showsCameraControls based on orientation since UIImagePickerController has to run in portrait.

- (void) orientationChanged:(NSNotification *)notification {
    [self showControls];
}

- (void) showControls {
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;

    if (UIDeviceOrientationIsLandscape(deviceOrientation)) {
        pickerController.showsCameraControls = YES;

    } else if (UIDeviceOrientationIsPortrait(deviceOrientation)) {
        pickerController.showsCameraControls = NO;
    }
}

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
[self showControls];

This works fine. However when the device is rotated the camera controls are out of place.

Is the only solution here to use AVFoundation instead of UIImagePickerController?

Landscape and controls out of place.

landscape

Portrait and no controls just like we want.

enter image description here

1

1 Answers

0
votes

If you go to CDVCamera.m file and add this 2 methods between @implementation CDVCameraPicker and @end, it should force the video to be recorded in landscape

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}