venkat
venkat

Reputation: 762

Disable Landscape Orientation in IOS5

I want to eliminate Landscape Orientation in my application, which is built for IOS 5. In IOS 6 I know this is possible - but it doesn't seem to be working for me in the earlier version.

I am setting only two orientations in my plist file (Portrait w/Home Button on Top and Portrait w/Home Button on Bottom). Regardless, Landscape still crops up in IOS 5.

Is there something further I need to do to eliminate this from happening?

Upvotes: 0

Views: 646

Answers (2)

RKY
RKY

Reputation: 266

This will work. Go to storyboard deselect the orientation you don't want and in view controller, write this code:

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

Upvotes: 0

NiravPatel
NiravPatel

Reputation: 3260

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
   // return (interfaceOrientation == UIInterfaceOrientationPortrait);
   if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||interfaceOrientation == UIInterfaceOrientationLandscapeRight)
 {
   return NO;
 }
 else
 {
   return YES;
 }

}

write this code in .m file for ios5 orientation

let me know it is working or not....

Happy Coding!!!!

Upvotes: 1

Related Questions