自动布局指南:UIImagePickerController W /自定义叠加不会旋转

问题描述 投票:0回答:1

我有一个带有自定义叠加层的UIImagePickerController。在叠加层的nib文件中,我为两个不同大小的类设置了UI约束,wc hR用于纵向,wC hC用于横向。为正确的大小类安装每个约束。

但是,当我转动相机风景时它不会旋转。我这样设置我的UIImagePickerController

- (void)viewDidAppear:(BOOL)animated
{

    [super viewDidAppear:animated];


    _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
        ipc.showsCameraControls = NO;

        [[NSBundle mainBundle] loadNibNamed:@"SnapItCameraView" owner:self options:nil];
        self.overlayView.frame = ipc.cameraOverlayView.frame;
        ipc.cameraOverlayView = self.overlayView;
        self.overlayView = nil;

        CGSize screenBounds = [UIScreen mainScreen].bounds.size;

        CGFloat cameraAspectRatio = 4.0f/3.0f;

        CGFloat camViewHeight = screenBounds.width * cameraAspectRatio;
        CGFloat scale = screenBounds.height / camViewHeight;
        ipc.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenBounds.height - camViewHeight) / 2.0);
        ipc.cameraViewTransform = CGAffineTransformScale(ipc.cameraViewTransform, scale, scale);

        ipc.showsCameraControls = NO;
        ipc.tabBarController.tabBar.hidden = YES;
        ipc.allowsEditing = YES;
        [ipc setAllowsEditing:YES];


    }else{
        ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }

    [self presentViewController:ipc animated:YES completion:nil];
    [_activityIndicator stopAnimating];

}
ios objective-c rotation uiimagepickercontroller
1个回答
0
投票

来自Apple的文档:

重要

UIImagePickerController类仅支持纵向模式。

参考:https://developer.apple.com/documentation/uikit/uiimagepickercontroller?language=objc

© www.soinside.com 2019 - 2024. All rights reserved.