New-Krish-15

Since iOS updated some orientation relative methods are not working and app orientation support is broken. The following two scenarios are the most of the user have issues in iOS 6 fixing these is really easy with the simple code changes as shown below.

  1.  Deprecated:
 
– (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
             return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

This method is deprecated in iOS 6, instead of this we need to use these two methods:

-(NSUInteger) supportedInterfaceOrientations
{
         return UIInterfaceOrientationMaskLandscape;
}
 
-(BOOL)shouldAutorotate
{
        return YES;
}
  1. Deprecated:
        [self.window addSubview: mainController.view];
This method is deprecated so we need to use it as following.
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
          // warning: addSubView doesn’t work on iOS6
          [self.window addSubview: mainController.view];
}
else
{
           // use this method on ios6
         [self.window setRootViewController:mainController];
}

Leave your comments and questions below.

  • Tarr

    Ive read setRootViewController is available since ios 4