ios 7图像选择器内部弹出错误的行为

时间:2022-02-25 15:01:16

My image picker view controller setted inside popover controller. On iOS 6 everything works great, but on iOS 7 the image is rotated and all movings are doing verse: when turning iPad left image is going down, when moving up image going left, etc.

我的图像选择器视图控制器设置在弹出控制器内。在iOS 6上,一切都很棒,但在iOS 7上,图像被旋转,所有移动都在做:当转动iPad时,左图像向下移动,向上移动图像时向左移动,等等。

Here is the code for showing my camera:

这是显示我的相机的代码:

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];

My app uses only landscape mode, now image is rotated: ios 7图像选择器内部弹出错误的行为

我的应用仅使用横向模式,现在图像被旋转:

3 个解决方案

#1


17  

As the Apple's Official Doc said:

正如Apple的官方文件所说:

Present the user interface. On iPhone or iPod touch, do this modally (full-screen) by calling the presentViewController:animated:completion: method of the currently active view controller, passing your configured image picker controller as the new view controller.

显示用户界面。在iPhone或iPod touch上,通过调用当前活动视图控制器的presentViewController:animated:completion:方法,以模态方式(全屏)执行此操作,将配置的图像选取控制器作为新视图控制器传递。

On iPad, the correct way to present an image picker depend on its source type, as summarized in this table:

在iPad上,呈现图像选择器的正确方法取决于其源类型,如下表所示:

  • Camera Photo: Use full screen
  • 相机照片:全屏使用
  • Library Saved: Must use a popover
  • 库已保存:必须使用弹出窗口
  • Photos Album: Must use a popover
  • 相册:必须使用popover

...

...

On iPad, if you specify a source type of UIImagePickerControllerSourceTypeCamera, you can present the image picker modally (full-screen) or by using a popover. However, Apple recommends that you present the camera interface only full-screen.

在iPad上,如果指定源类型为UIImagePickerControllerSourceTypeCamera,则可以模态(全屏)或使用弹出窗口显示图像选择器。但是,Apple建议您仅全屏显示相机界面。

Though it said "you can present the image picker modally (full-screen) or by using a popover", as you see by using a popover will result with this weird issue. I guess this might be a bug on iOS 7 SDK.

虽然它说“你可以模态地(全屏)或使用弹出窗口呈现图像选择器”,正如你所看到的那样使用弹出窗口会导致这个奇怪的问题。我想这可能是iOS 7 SDK上的一个错误。

I'm still trying to fix this issue, but for now, the only way I can tell is to show it modally by

我仍在努力解决这个问题,但就目前而言,我能告诉他的唯一方法是以模态方式显示它

-presentViewController:animated:completion:

method, which is in full-screen (Actually, I don't like this way).

方法,全屏显示(实际上,我不喜欢这种方式)。

And there's a THREAD discussed about it on Apple's Dev Forums, you can take a look at it. ;)

在Apple的Dev Forums上讨论了一个关于它的THREAD,你可以看看它。 ;)

#2


6  

Try the following:

请尝试以下方法:

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];

credit to https://*.com/a/19071958/1363779

信用到https://*.com/a/19071958/1363779

#3


0  

The only one way which work properly in iOS7 is using of

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

-presentViewController:animated:completion:

-presentViewController:动画:完成:

You can try to change camera view transformation by cameraViewTransform property but result will be ugly. Adding of view to custom ViewController (which rotate to landscape) will give You ugly results too. I begin to hate this os version.

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

#1


17  

As the Apple's Official Doc said:

正如Apple的官方文件所说:

Present the user interface. On iPhone or iPod touch, do this modally (full-screen) by calling the presentViewController:animated:completion: method of the currently active view controller, passing your configured image picker controller as the new view controller.

显示用户界面。在iPhone或iPod touch上,通过调用当前活动视图控制器的presentViewController:animated:completion:方法,以模态方式(全屏)执行此操作,将配置的图像选取控制器作为新视图控制器传递。

On iPad, the correct way to present an image picker depend on its source type, as summarized in this table:

在iPad上,呈现图像选择器的正确方法取决于其源类型,如下表所示:

  • Camera Photo: Use full screen
  • 相机照片:全屏使用
  • Library Saved: Must use a popover
  • 库已保存:必须使用弹出窗口
  • Photos Album: Must use a popover
  • 相册:必须使用popover

...

...

On iPad, if you specify a source type of UIImagePickerControllerSourceTypeCamera, you can present the image picker modally (full-screen) or by using a popover. However, Apple recommends that you present the camera interface only full-screen.

在iPad上,如果指定源类型为UIImagePickerControllerSourceTypeCamera,则可以模态(全屏)或使用弹出窗口显示图像选择器。但是,Apple建议您仅全屏显示相机界面。

Though it said "you can present the image picker modally (full-screen) or by using a popover", as you see by using a popover will result with this weird issue. I guess this might be a bug on iOS 7 SDK.

虽然它说“你可以模态地(全屏)或使用弹出窗口呈现图像选择器”,正如你所看到的那样使用弹出窗口会导致这个奇怪的问题。我想这可能是iOS 7 SDK上的一个错误。

I'm still trying to fix this issue, but for now, the only way I can tell is to show it modally by

我仍在努力解决这个问题,但就目前而言,我能告诉他的唯一方法是以模态方式显示它

-presentViewController:animated:completion:

method, which is in full-screen (Actually, I don't like this way).

方法,全屏显示(实际上,我不喜欢这种方式)。

And there's a THREAD discussed about it on Apple's Dev Forums, you can take a look at it. ;)

在Apple的Dev Forums上讨论了一个关于它的THREAD,你可以看看它。 ;)

#2


6  

Try the following:

请尝试以下方法:

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];

credit to https://*.com/a/19071958/1363779

信用到https://*.com/a/19071958/1363779

#3


0  

The only one way which work properly in iOS7 is using of

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

-presentViewController:animated:completion:

-presentViewController:动画:完成:

You can try to change camera view transformation by cameraViewTransform property but result will be ugly. Adding of view to custom ViewController (which rotate to landscape) will give You ugly results too. I begin to hate this os version.

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