【发布时间】:2018-08-10 22:15:39
【问题描述】:
我有一个带有自定义叠加层的 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