Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable landscape orientation for iOS 7 application? [duplicate]

First time developer and have just setup the certificates to be able to run my application on an iOS device.

My application does not view nicely in landscape mode even with Autolayout setup. How can I disable the user from being able to view the app in landscape when they turn the device? i.e. its always portrait regardless of the orientation of the device? thanks

EDIT: Does Apple also advise against doing this during submission?

like image 992
Cescy Avatar asked Jan 22 '14 01:01

Cescy


People also ask

How do I turn off landscape mode in iOS?

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 stop my swift app from rotating?

Go it the main and select TARGETS then select Info tab (the plist) and open Supported inferface orientations (iPhone) the click on the ones that you do not need. Just leave Portrait(bottom home button) . That should make the UI stay one way.


2 Answers

As Siavash said, the General Tab in your Target is the best place to limit the orientations for the entire device. Device orientations

If you wanted to set all orientations possible but limit it for certain View Controllers, you could do something like this:

- (BOOL) shouldAutorotate
{
    return NO;
}

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return NO;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    if (condition)
    {
        return UIInterfaceOrientationPortrait;
    }else{
        return UIInterfaceOrientationLandscapeLeft;
    }
}

To answer your second question, Apple does not critique an app based on its possible orientations. It's more up to you to decide which orientation(s) is/are best suited for your app. For iPhone Apps, users prefer Portrait usually for example (unless it's a game!).

like image 50
Nathaniel Avatar answered Sep 19 '22 15:09

Nathaniel


The easiest way is to go to your project file and under the Deployment info part, check the orientation that you want to have for each device.

Edit: Here is the picture for your reference:

image

like image 26
Siavash Alp Avatar answered Sep 21 '22 15:09

Siavash Alp