iPad UIImagePickerControllerSourceTypeCamera强制旋转导致不正确的父模态视图原点

时间:2014-06-23 12:19:57

标签: ios ipad orientation uiimagepickercontroller presentmodalviewcontroller

我有一个样式UIModalPresentationFormSheet的模态视图,它提供了一个UIImagePickerControllerSourceTypeCamera。表单模式视图从自定义视图控制器容器

中显示

图像选择器强制应用更改为纵向。如果在取消图像选择器之前将应用程序旋转到纵向模式,则一切正常。

但是,在设备处于横向状态时取消图像选择器后,表单样式模式视图现在位于其父框架的左上角(参见图像)。

orientation changes

我猜想模态视图的超级视图不会在后台旋转。但是,一旦取消图像选择器,模态视图的帧就会被设置为。

1 个答案:

答案 0 :(得分:0)

Create a custom class of UIImagePickerController. Override supportedInterfaceOrientations meted
- (NSUInteger) supportedInterfaceOrientations
{
    //Because your app is only landscape, your view controller for the view in your
    // popover needs to support only landscape
    return UIInterfaceOrientationMaskAll;
}
-(BOOL)shouldAutorotate{
    return yes;
}

//call custom view like this
   CustomImagePickerViewController *picker = [[CustomImagePickerViewController alloc] init];
        picker.supportedInterfaceOrientations= UIInterfaceOrientationMaskAll;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        picker.delegate = self;
        [self presentViewController:picker animated:YES completion:nil];