Rotate iOS 6 Compatible iOS 5

I am working on an application (Xcode 4.5 iOS 6), it must be compatible for devices with installed software version starting from version 4.5 and the default iPhone 5.

I know that new iOS 6 changes have appeared in auto-rotate mode.

When I turn on the device, the iPhone Simulator 6.0 application works fine, but when I run the iPhone Simulator 5.0 problems in the rotation path.

I introduced the code, as well as new ways to turn off with iOS 6 and the old method (deprecated) on iOS 5.

Look for rotation methods:

#pragma mark - Rotate Methods - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAllButUpsideDown; } - (BOOL) shouldAutorotate { return YES; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } #pragma mark - Rotate Methods iOS 5 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { [menuPortrait setHidden:NO]; [menuLandscape setHidden:YES]; } if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) { [menuPortrait setHidden:YES]; [menuLandscape setHidden:NO]; } return YES; } - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) { [self.menuLandscape setHidden:YES]; [self.menuPortrait setHidden:NO]; } if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { [self.menuLandscape setHidden:NO]; [self.menuPortrait setHidden:YES]; } [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; } 

Can you help me with some tips on this issue? Thank you in advance for your answers!

+4
source share
1 answer

I achieved this by subclassing the entire view controller as follows:

//. #Import

 @interface ITViewController : UIViewController @end 

// m.

 #import "ITViewController.h" @interface ITViewController () @end @implementation ITViewController - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } 

This orientation mode is orientation. You can update the contents of both methods according to the desired behavior.

+3
source

Source: https://habr.com/ru/post/1442100/


All Articles