【问题标题】:showsCameraControls only in landscape UIImagePickerController仅在横向 UIImagePickerController 中显示CameraControls
【发布时间】:2016-01-29 00:22:38
【问题描述】:

所以我试图强制用户使用 UIImagePickerController 以横向模式录制视频。

我认为一个好方法是根据方向切换 showCameraControls,因为 UIImagePickerController 必须以纵向运行。

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

这很好用。但是,当设备旋转时,相机控件不合适。

这里唯一的解决方案是使用 AVFoundation 代替 UIImagePickerController 吗?

景观和控件不合适。

纵向,没有我们想要的控件。

【问题讨论】:

    标签: ios objective-c cordova uiimagepickercontroller cordova-plugins


    【解决方案1】:

    如果你去CDVCamera.m文件并在@implementation CDVCameraPicker@end之间添加这2个方法,它应该强制视频以横向录制

    - (BOOL)shouldAutorotate {
        return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskLandscape;
    }
    

    【讨论】:

    • 这会导致录制视图失真,但视频文件在录制后会正确呈现。见recording view screenshot。文本行应该是水平的。
    猜你喜欢
    • 2011-01-06
    • 2013-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-17
    • 1970-01-01
    相关资源
    最近更新 更多