Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop only iPhone screen rotating in Universal Xcode 6 project

With the introduction of Xcode 6, Apple removed the ability to easily have multiple storyboards for iPad and iPhone in Universal apps. Due to this, you cannot differentiate between iPad and iPhone on the rotation panel/settings.

How can i stop the iPhone app from Rotating into landscape, while still allowing the iPad app to do so.

Is it something you can only do in code? If it is, I am still using Objective C, not Swift.

like image 820
InfinityLoop Avatar asked Aug 26 '14 17:08

InfinityLoop


People also ask

How do I stop my iPhone from rotating the screen?

Swipe down from the top-right corner of your screen to open Control Center. Tap the Portrait Orientation Lock button to make sure that it's off.

How do I force an app to landscape in iOS?

On an iPhone with a Home button, swipe up from the bottom of the screen to access it. On an iPhone without a Home button, swipe down from the top-right corner of the screen instead. Here, tap on the rotation lock icon (which looks like a lock with a circular arrow) to turn it on or off.

How do I set auto rotate on iOS?

To disable Screen Rotation Lock, unlock your iPhone so that you're on the home screen and swipe down from the top right of your screen to reveal the Control Center. 2. Locate the icon featuring a small lock with an arrow curving around it. If Screen Rotation Lock is active, this will appear highlighted.


2 Answers

Remove all the other answers' code. Go to your info.plist file and add the following.

  • "Supported Interface Orientations" - Array
    • "Portrait (bottom home button)" - String
    • "Portrait (top home button)" - String
  • "Supported Interface Orientations (iPad)" - Array
    • "Portrait (bottom home button)" - String
    • "Portrait (top home button)" - String
    • "Landscape (left home button)" - String
    • "Landscape (right home button)" - String
like image 200
gjsalot Avatar answered Oct 10 '22 02:10

gjsalot


Check out THIS answer.

Basically you'd have to implement Chris1994's answer on a UINavigationController or UITabBarController subclass and then add the following to the first UIVIewController subclass you have on that Nav or Tab Controller :

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
like image 29
Benjamin Avatar answered Oct 10 '22 03:10

Benjamin