【问题标题】:Horizontal Camera with Overlay带叠加层的水平相机
【发布时间】:2016-01-27 20:45:47
【问题描述】:

我需要一个带有图像覆盖(未记录)的水平摄像机输入。

问题在于,当处于活动状态时,相机视图会旋转 90 度,即使其他一切都正确地水平定向。

UIImagePicker 无法进行水平方向,并且我在使用带有图形覆盖的 AVCapture 时遇到了问题。所以,我使用自定义视图并旋转它。

相机初始化

 if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
 {
    //Custom View Instead of UIImagePicker
    _video_picker = [[VCImagePickerController alloc] init];

    _video_picker.delegate = self;
    _video_picker.allowsEditing = YES;
    _video_picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    _video_picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
    _video_picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
    _video_picker.showsCameraControls = NO;

    //Set the orientation
    _video_picker.modalPresentationStyle = UIModalPresentationCurrentContext;

    //Display overlay graphics
    _video_picker.cameraOverlayView = _overVW ;

    [self.navigationController presentViewController:_video_picker animated:NO completion:nil];

然后在自定义的 VCImagePickerController 视图中,设置掩码:

- (BOOL)shouldAutorotate
{
    return YES;
}

-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;  
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

当相机处于水平模式时,就像渲染视图不同步一样。蒙版出现,但实际相机视图不正确。当我将相机向右移动时,它会下降,就好像方向旋转了一样。 使用装有 iOS 9.2.1 的 iPhone 6。

【问题讨论】:

    标签: ios iphone camera orientation


    【解决方案1】:

    如果它对任何人有帮助,要制作水平 UIImagePicker ,您必须创建一个完全自定义的视图。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-18
      • 2018-10-25
      • 1970-01-01
      • 1970-01-01
      • 2019-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多