Saturday, July 14, 2012

Problem in Landscape Orientation iPad

I have faced this problem very often. When you intend to make your project work only in Landscape mode specially in iPad, you will see that even you have put the code -

- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
  //Return YES for supported orientations
    return NO;
}
 
It is showing weird. It is just showing your project in Portrait. Even if you have put the project settings just for LandscapeLeft and LandscapeRight. Your app is just not working in Landscape!

To get rid of this problem you should follow the following code -

- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation

{

    // Return YES for supported orientations

    return UIInterfaceOrientationIsLandscape(interfaceOrientation);

}



Thats it! Then your code will work perfectly in Landscape mode only both in Right and Left!

Enjoy!