0
votes

I have implemented sample code in IOS 6.0 with orientation support its works fine but the same application if I run in ipad 1 (IOS 5.1) orientation not supported.I know that IOS 6.0 Deprecated some method in iOS 5.1 how to resolve this?

3

3 Answers

1
votes

You need to implement the old rotation methods in you view controllers to support iOS 5 or lower rotation.

Yes the methods have been deprecated but are still need by the older versions of iOS.

1
votes

For iOS 6+ use these methods

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotate {

    return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

and for iOS 5.0 and all previous use this

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{  
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
0
votes

Use the following code in .m file.

// Override to allow orientations other than the default portrait orientation.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)  {
           return NO;
}
else {
    return YES;
}

}

This works in iOS 5.1,6.1.3 and 7.0.2.