4

我正在开发一个使用旧 X-Code 版本创建的 iOS 应用程序,因此它在 MainWindow.xib 中有窗口。最近在 iOS8 Beta 版本中运行这个项目时,我遇到了一个问题:窗口没有横向旋转。所以我在 MainWindow.xib 中添加了另一个窗口。我设置了 if 条件来检查操作系统版本,对于较旧的 iOS 版本,我使用以前创建的窗口,但对于 iOS8,我使用新添加的横向窗口。我已经解决了这个问题。除相机外,整个应用程序工作正常。

以下是屏幕截图。

在 LandscapeMode 中(它工作正常): 在此处输入图像描述

在 PortraitMode(一旦相机被加载,我已经旋转它,这里其他控件旋转正常,但相机过度旋转不正确):

在此处输入图像描述

以横向模式加载相机后,我旋转了设备,控件正常旋转但相机屏幕没有旋转,它仍处于纵向模式。这可能是由于 Appdelegate 中的窗口所致。

有什么解决办法吗?

提前致谢。

4

3 回答 3

1

Have posted what I believe is a solution, over at; https://stackoverflow.com/a/26934067/782533

Looks like the same issue? Not sure if I'm supposed to link or copy/paste, so here it is anyway;

I had the same issue and after getting back to basics and creating a new project which actually worked.. I tracked it down to;

-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
    // Had forgot to call the following..
    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}

Hope it helps.

于 2014-11-14T16:11:16.947 回答
1

我有同样的问题。
我试图使用cameraViewTransform。

以下

#import "MyUIImagePickerController.h"

@implementation MyUIImagePickerController

bool rotateFlg = false;
UIInterfaceOrientation startupOrientation;

-(id)init{
    startupOrientation = [[UIApplication sharedApplication] statusBarOrientation];
    return [super init];
}

-(NSUInteger)supportedInterfaceOrientations {
    // iOS 8
    if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) {
        float lotate[4];
        if (startupOrientation == UIInterfaceOrientationLandscapeRight || startupOrientation == UIInterfaceOrientationLandscapeLeft) {
            lotate[0] = 90.0f;
            lotate[1] = -90.0f;
            lotate[2] = 180.0f;
            lotate[3] = 0.0f;
        } else {
            lotate[0] = 0.0f;
            lotate[1] = 180.0f;
            lotate[2] = 90.0f;
            lotate[3] = -90.0f;
        }

        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
        if(orientation ==UIInterfaceOrientationPortrait ){
            CGAffineTransform __rotation = CGAffineTransformMakeRotation(lotate[0] * M_PI / 180.0f);
            self.cameraViewTransform = __rotation;
            rotateFlg = true;
        }
        else if(orientation == UIInterfaceOrientationPortraitUpsideDown){
            CGAffineTransform __rotation = CGAffineTransformMakeRotation(lotate[1] * M_PI / 180.0f);

            self.cameraViewTransform = __rotation;
            rotateFlg = true;
        } else if(orientation == UIInterfaceOrientationLandscapeLeft){
            if (rotateFlg) {
                CGAffineTransform __rotation = CGAffineTransformMakeRotation(lotate[2] * M_PI / 180.0f);
                self.cameraViewTransform = __rotation;
                rotateFlg = false;
            }
        }else if(orientation == UIInterfaceOrientationLandscapeRight){
            if (rotateFlg) {
                CGAffineTransform __rotation = CGAffineTransformMakeRotation(lotate[3] * M_PI / 180.0f);
                self.cameraViewTransform = __rotation;
                rotateFlg = false;
            }
        }
    }
    return UIInterfaceOrientationMaskAll;
}
@end

它似乎工作
但来源并不美丽......

于 2014-09-19T10:35:31.010 回答
0

根据Apple Dev forums 上的这个帖子,iOS8/XCode6 中的轮换在使用 XIB 时会出现一些问题,但在使用 Storyboard 时不会出现问题。

于 2014-09-16T16:53:10.663 回答