Sunday, October 14, 2012

iOS6 - shouldAutorotateToInterfaceOrientation not called

Haven't written on the blog for a while now - here's a good reason for doing that: when launching an older app (that was build on iOS4) in the new iOS 6 simulator, I discovered that the shouldAutorotateToInterfaceOrientation is not called.

After a little digging, I found out that this is the new behavior for new iOS 6 that is NOT backward compatible... WTF Apple, really?...

So, If you see old apps that act funny on the new iPhones, you should know that developers have nothing to do with that...

Here's how this can be "fixed" - for landscape in this particular case:

1. Make sure that you set a root view controller that contains/is your displayed view controller.

    [self.window setRootViewController:nav];

2. Add the new methods in the displayed view controller

// this is for iOS < 6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation
    // Return YES for supported orientations
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);

//this is for iOS >= 6
//crappy iOS6 fix,'cause the should Autorotate to interface orientation doesnt get called
- (BOOL) shouldAutorotate
    return YES;
//    UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
//    return [self shouldAutorotateToInterfaceOrientation:orientation];
- (NSUInteger)supportedInterfaceOrientations
    return UIInterfaceOrientationMaskLandscape;  

No comments:

Post a Comment