23

ポップオーバーコントローラー内に設定された私のイメージピッカービューコントローラー。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];

私のアプリは横向きモードのみを使用していますが、現在は画像が回転しています: ここに画像の説明を入力

4

3 に答える 3

6

次のことを試してください。

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へのクレジット

于 2014-02-06T20:16:40.510 に答える
0

iOS7 で適切に動作する唯一の方法は、

-presentViewController:アニメーション:完了:

cameraViewTransform プロパティでカメラ ビューの変換を変更しようとすることはできますが、結果は見苦しくなります。カスタムViewController(横向きに回転する)にビューを追加すると、醜い結果も得られます。私はこのOSバージョンが嫌いになり始めました。

于 2013-09-26T15:27:57.473 に答える