• Skip to main content
  • Skip to primary sidebar

Ravi Shankar

Tweaking Apps

  • Swift
  • Tech Tips
You are here: Home / Apple / How to only enable portrait orientation for iPhone App

How to only enable portrait orientation for iPhone App

June 14, 2012 By Ravi Shankar 2 Comments

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

 

Filed Under: Apple, Develop, iPhone Tagged With: device orientation, dsiable, iPhone app, portrait, Xcode

Reader Interactions

Trackbacks

  1. Apple iPhone Tutorials, Tips and Tricks says:
    April 10, 2013 at 11:01 pm

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

    Reply
  2. Apple iPhone Tutorials, Tips and Tricks says:
    April 10, 2013 at 11:01 pm

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

    Reply

Leave a Reply Cancel 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.

Primary Sidebar

TwitterLinkedin

Recent Posts

  • How to block keywords in Jio broadband
  • How to disable opening an app automatically at login in Mac
  • How to set preferred Wifi network on Mac
  • Attribute Unavailable: Estimated section warning before iOS 11.0
  • How to recover Firefox password from Time Machine backup

Pages

  • About
  • Privacy Policy
  • Terms and Conditions

Copyright 2022 © rshankar.com

Terms and Conditions - Privacy Policy