相关疑难解决方法(0)

iPad iOS7 - UIPopoverController中的UIImagePickerController具有错误的预览图像

我在UIPopoverController中使用UIImagePickerController,它与iOS6完美配合.使用iOS 7时,显示捕获图像的"预览"图像会旋转,但如果我拍照,则会正确保存.

这就是我选择的方式:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
                              (NSString *) kUTTypeImage,
                              nil];
imagePicker.allowsEditing = NO;
Run Code Online (Sandbox Code Playgroud)

并将其添加到弹出控制器:

self.imagePickerPopOver = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
    [self.imagePickerPopOver presentPopoverFromRect:CGRectMake(aPosViewA.x, cameraButton_y, 100.0, 30.0) inView:self.detailViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Run Code Online (Sandbox Code Playgroud)

这些是UIScrollView上按钮位置的计算,以显示正确位置的弹出窗口:

presentPopoverFromRect:CGRectMake(aPosViewA.x, cameraButton_y, 100.0, 30.0)
Run Code Online (Sandbox Code Playgroud)

我不认为问题就在那里,因为我尝试了几种组合.

我还尝试在全屏模式下捕获图像,但应用程序只允许使用横向模式.如果以纵向模式拍摄图像并且取消模态视图,则应用程序也将保持纵向模式.如果模态视图被解除,我找不到阻止UIImagePickerController切换到纵向模式或强制应用程序回到横向模式的方法.

UPDATE

我从这里得到了答案,又向前迈进了一步.

我在创建选择器之后和显示弹出窗口之前转换视图:

switch ([UIApplication sharedApplication].statusBarOrientation) {
        case UIInterfaceOrientationLandscapeLeft:
            self.imagePicker.view.transform = CGAffineTransformMakeRotation(M_PI/2);
            break;
        case UIInterfaceOrientationLandscapeRight:
            self.imagePicker.view.transform = CGAffineTransformMakeRotation(-M_PI/2);
            break;
        default:
            break;
    }
Run Code Online (Sandbox Code Playgroud)

只要我不转动iPad,它就能正常工作.为此,我正在注册方向更改事件:

[[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(orientationChanged:)  name:UIDeviceOrientationDidChangeNotification  object:nil];
Run Code Online (Sandbox Code Playgroud)

并更改选择器视图:

- …
Run Code Online (Sandbox Code Playgroud)

uiimagepickercontroller uipopovercontroller uiinterfaceorientation ios ios7

26
推荐指数
1
解决办法
9834
查看次数