popup里面的ios 7图像select器错误的行为

我的图像select器视图控制器设置在popover控制器。 在iOS 6上,一切都很好,但是在iOS 7上,图像被旋转了,所有的动作都在进行:当iPad左转时,图像向左移动,等等。

以下是显示我的相机的代码:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; objPopView = [[UIPopoverController alloc] initWithContentViewController:imagePicker]; [objPopView presentPopoverFromRect:CGRectMake(842, 163, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; 

我的应用程序只使用横向模式,现在图像旋转: 在这里输入图像说明

正如苹果官方文件所言:

呈现用户界面。 在iPhone或iPod touch上,通过调用当前活动的视图控制器的presentViewController:animated:completion:方法,通过将已configuration的图像选取器控制器作为新的视图控制器进行模态(全屏)操作。

iPad上 ,呈现图像select器的正确方法取决于其源types,如下表所示:

  • 相机照片:使用全屏
  • 保存库:必须使用popover
  • 照片相册:必须使用popover

在iPad上,如果您指定了UIImagePickerControllerSourceTypeCamera的源types,则可以以模态方式(全屏)或使用popup窗口来呈现图像select器。 但是, Applebuild议您仅以全屏方式呈现相机界面

虽然它说“你可以模式地展示图片select器(全屏)或使用popup窗口” ,正如你所看到的使用popup窗口会导致这个奇怪的问题。 我想这可能是iOS 7 SDK的一个错误。

我仍然试图解决这个问题,但现在,我能告诉的唯一方法是通过模式显示它

 -presentViewController:animated:completion: 

方法,这是全屏(其实,我不喜欢这种方式)。

在苹果开发者论坛上有一个关于它的讨论,你可以看看它。 ;)

尝试以下操作:

 UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; CGFloat scaleFactor=1.3f; switch ([UIApplication sharedApplication].statusBarOrientation) { case UIInterfaceOrientationLandscapeLeft: imagePicker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * 90 / 180.0), scaleFactor, scaleFactor); break; case UIInterfaceOrientationLandscapeRight: imagePicker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * -90 / 180.0), scaleFactor, scaleFactor); break; case UIInterfaceOrientationPortraitUpsideDown: imagePicker.cameraViewTransform = CGAffineTransformMakeRotation(M_PI * 180 / 180.0); break; default: break; } objPopView = [[UIPopoverController alloc] initWithContentViewController:imagePicker]; [objPopView presentPopoverFromRect:CGRectMake(842, 163, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; 

信贷到https://stackoverflow.com/a/19071958/1363779

唯一一个在iOS7中正常工作的方式是使用

-presentViewController:animation:完成:

您可以尝试通过cameraViewTransform属性更改相机视图转换,但结果会很难看。 添加视图到自定义的ViewController(旋转到横向)也会给你带来难看的结果。 我开始讨厌这个操作系统版本。