The app only works on iOS 6, not iOS 5

I made an application focused on iOS 5 and iOS 6, and for some reason it only rotates when used on devices with iOS 6, on iPhone or iPad and does not rotate on devices using iOS 5 My application is universal. Please help me solve this problem! Thanks

+4
source share
5 answers
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)); } - (NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown); } 

override these two methods in your subclasses of uiviewcontroller ...... this will work for ios 6 and earlier

+8
source

iOS 5 and iOS 6 are called different delegates of orientation and rotation. In iOS 5, do:

shouldAutorotateToInterfaceOrientation: which is deprecated in iOS 6.

So, in iOS 6, make sure you install the root view controller and implement:

shouldAutorotate :, supportedInterfaceOrientations and supportedInterfaceOrientationsForWindow:

+5
source

I had a similar problem. You can check the answer to this question:

Rotation behaves differently on iOS6

To summarize, in order for autorotation to fully work in iOS 5 and iOS 6, as well as for self.window.rootViewController orientation, I had to implement a custom UINavigationController and assign it self.window.rootViewController in the didFinishLaunchingWithOptions delegate didFinishLaunchingWithOptions .

0
source

shouldAutorotateToInterfaceOrientation is deprecated in ios6.

therefore, if you run the application on both versions of os, add shouldAutorotateToInterfaceOrientation, as shown below.

 //for ios6 - (BOOL)shouldAutorotate { UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation]; if (orientation == UIInterfaceOrientationLandscapeLeft ||orientation == UIInterfaceOrientationLandscapeRight ) { return YES; } return NO; } //for ios5 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { //interfaceOrientation == UIInterfaceOrientationLandscapeRight; if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||interfaceOrientation == UIInterfaceOrientationLandscapeRight ) { return YES; } return NO; } 
0
source

to support autorotations in ios5 and ios6, we need to provide callbacks in case of ios6 .... `[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; 

and we need to call

 - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; 

}

 -(BOOL)shouldAutoRotate{ return YES; } 

for ios5

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 

{return ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)); }

-1
source

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


All Articles