Camera doesn't rotate properly in iOS8 beta for older projects

I am working on an iOS application that is created using the old version of X-Code, so it has a window in MainWindow.xib. Recently, when I launch this project in the beta version of iOS8, I had a problem: the window does not rotate in landscape orientation. So I added another window to MainWindow.xib. I made, if the condition for checking OS versions, for an older version of iOS, I use a previously created window, but for iOS8 I use a newly added window for landscape orientation. I solved the problem. The whole application works correctly, except for the camera.

Below are screenshots.

In LandscapeMode (it works correctly): enter image description here

PortraitMode ( , , , , ):

enter image description here

, , , , . Appdelegate.

?

.

+4
3

.
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

,
...

+1

, , , , ; fooobar.com/questions/140523/...

? , /, ,

, , . :

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

, .

+1

Apple Dev iOS8/XCode6 XIB, .

0

All Articles