Support for both authorized iOS 6 and iOS 5

Can someone confirm that it doesn't make sense to add new iOS 6 autorotation methods to support iOS 6 and iOS 5, as Apple docs suggest that these methods be completely ignored if you also use iOS 5 methods?

In particular, I'm talking about the methods - (NSUInteger)supportedInterfaceOrientations and - (BOOL) shouldAutorotate - that they are ignored and synthesized by the compiler, if you also implement - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

+12
ios objective-c iphone uikit uiviewcontroller
Sep 15
source share
6 answers

You need to add a new callback for autorotation if you pack your application in a new sdk. However, these callbacks will only be received when the application is launched on iOS devices 6. For devices running earlier versions of iOS, earlier callbacks will be received. If you are not making new callbacks, the default behavior is that your application works with all orientation on the iPad and all but the orientation of UpsideDown on the iPhone.

+8
Sep 17 '12 at 9:38
source share

To rotate iOS5. Check the desired orientation and return YES.

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if ((interfaceOrientation==UIInterfaceOrientationPortrait)||(interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)) { return YES; } else return NO; } 

Support for iOS 6.0 autorotation

 - (BOOL)shouldAutorotate { return NO; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationIsPortrait(UIInterfaceOrientationMaskPortrait|| UIInterfaceOrientationMaskPortraitUpsideDown); } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationIsPortrait(UIInterfaceOrientationPortrait|| UIInterfaceOrientationPortraitUpsideDown); } 
+8
Dec 10 '12 at 12:25
source share
  - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationMaskAll; } -(void)viewWillLayoutSubviews { if([self interfaceOrientation] == UIInterfaceOrientationPortrait||[self interfaceOrientation] ==UIInterfaceOrientationPortraitUpsideDown) { if (screenBounds.size.height == 568) { //set the frames for 4"(IOS6) screen here } else { ////set the frames for 3.5"(IOS5/IOS6) screen here } } else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight) { if (screenBounds.size.height == 568) { //set the frames for 4"(IOS6) screen here } else { ////set the frames for 3.5"(IOS5/IOS6) screen here } } //it is for IOS5 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } 

- (void) viewWillLayoutSubviews, this method will call ios5 / ios6. This code is useful for ios6 / ios5 / ios6 with 3.5 "screen / 4" screen with ios6.

+1
Nov 22
source share

I think the most elegant solution:

 - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return ((1 << toInterfaceOrientation) & self.supportedInterfaceOrientations) != 0; } 

Did I miss something?

+1
Dec 03
source share

You should set a flag somewhere (I believe in your Info.plist) that indicates which of the two you are using. If you are using a new one, you cannot create for iOS 5 (or at least it won’t work on iOS 5). If you use the old, new methods do not call. So yes, you pretty much have to choose which method you want to use, and if you want to support iOS 5, you can't use the new methods.

0
Sep 15 '12 at 6:13
source share

to support autorotation in both ios5 and ios6, we need to provide callbacks in the 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)); } 
0
Aug 22 '13 at 7:24
source share



All Articles