4
votes

I'm working on an iOS Application which is created using older X-Code version, so it has window in MainWindow.xib. Recently when I run this project in iOS8 Beta version, I got a problem: window is not rotating in landscape orientation. So I have added another window in MainWindow.xib. I made if condition to check OS Versions, for older iOS version I'm using previously created window but for iOS8 I'm using newly added window for landscape orientation. I have solved the problem. The entire application is working properly except the camera.

Below are screen shots.

In LandscapeMode(It's working properly): enter image description here

In PortraitMode(Once camera is loaded, i have rotated it,Here other controls are rotating properly, but camera overly is not rotating properly):

enter image description here

Once Camera is loaded in landscape mode I have rotated device, the controls are rotating properly but the camera screen is not rotating, it is still in portrait mode. This may be due to window in Appdelegate.

Any solution for this?

Thanks in advance.

3
Check the camera app... maybe is a bug of the beta versionAndrea
No, I haven't solved it. @Boni2kAshok
Have the same issue here! - To the close votes: it's rather difficult to give a correct code example, as the parts dealing with iOS app rotation are far and wide between!Blitz
I am having the exact issue. strange behavior when launched in portrait, launching it in landscape seems to be fine.Rufus
@Rufus yes, the "starting" orientation works fine. Rotating it messes up the picture. This is even reproducable in a very basic UIImagePickerController project. Only the camera controls should rotate but the preview itself should not...Boni2k

3 Answers

1
votes

I am having the same issue.
I was tryed to use the cameraViewTransform.

Below

#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

It seems to work
But the source is not beautiful ...

1
votes

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.

0
votes

According to this thread on Apple Dev forums rotation in iOS8/XCode6 has some problems when using XIBs but not when using Storyboards.