Question

I have created an iphone app which is only in portrait orientation,even though i have made one view supporting landscape orientation also while rotating the device Everything works fine in iOS6 but when i run it on iOS5,the landscape mode is not proper it shows some nasty images. (both devices are ipod 3.5" retina display)

Why is this happening??

Adding my codes and screen shots here

In iOS6 first view After rotating the device in iOS 5

first view After rotating the device -(void)viewDidLoad { [super viewDidLoad];

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(didRotate:)
                                               name:UIDeviceOrientationDidChangeNotification
                                           object:nil];


}



- (void)didRotate:(NSNotification *)notification {
UIDeviceOrientation orientation = [[notification object] orientation];

if (orientation == UIDeviceOrientationLandscapeLeft) {
    [self.grpView setTransform:CGAffineTransformMakeRotation(M_PI / 2.0)];
   imageScrollView.frame =CGRectMake(-50, -100, 400, 620);



} else if (orientation == UIDeviceOrientationLandscapeRight) {
    [self.grpView setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
} else if (orientation == UIDeviceOrientationPortraitUpsideDown) {
    [self.grpView setTransform:CGAffineTransformMakeRotation(M_PI)];
} else if (orientation == UIDeviceOrientationPortrait) {
    [self.grpView setTransform:CGAffineTransformMakeRotation(0.0)];

}
}
Was it helpful?

Solution

InterfaceOrientation method is got deprecated in ios6. So that if you want your orientation supported by both ios5 & ios6, you have to write two extra methods for ios6 along with

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// your customisation will go here
}

Two extra methods for ios6

    - (BOOL)shouldAutorotate
    {
        return YES;
    }

    - (NSUInteger)supportedInterfaceOrientations
       {
   // your customisation will go here
       }

Enjoy Programming!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top