How to only enable portrait orientation for iPhone App

When developing an iPhone app in Xcode, if you have any requirement that only portrait orientation allowed then you can do the following.

Step 1: Open the implementation file for editing.

Step 2. Navigate to shouldAutorotateToInterfaceOrientation method. This methods is auto generated by Xcode while creating the project.

Step 3: replace the return statement with return (interfaceOrientation == UIInterfaceOrientationPortrait);. The update method should be displayed as shown below.

– (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

This method will return true only when the orientation in Portrait mode.

Step 4: Now navigate to Project Folder on the navigattion bar. In the summary tab under Supported Device Orientations, make sure to un mark the other orientation except portrait.

Portrait Device Orientation

 


Comments

2 responses to “How to only enable portrait orientation for iPhone App”

  1. […] How to only enable portrait orientation for iPhone App […]

  2. […] How to only enable portrait orientation for iPhone App […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.