Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Landscape Mode ONLY for iPhone or iPad

I want to create an application that doesn't use Portrait mode.

I am not sure if I need to edit the plist or have code in addition to the plist

like image 808
Cocoa Dev Avatar asked Apr 15 '10 17:04

Cocoa Dev


People also ask

Does iPad have landscape mode?

The screen on your iPad can rotate so that you can see apps like Safari and Messages in portrait or landscape mode.

Does iPhone have landscape mode?

The screen on your iPhone and iPod touch can rotate so that you can see apps — like Safari and Messages — in portrait or landscape mode.

Which iphones support landscape mode?

Only the iPhone 6 Plus, 6S Plus, 7 Plus, and 8 Plus can rotate their Home Screens. There's thus no possibility of a landscape Home Screen on iPhone X or later, likely due to the Face ID camera position.


2 Answers

Code found here

Launching in Landscape Mode

Applications in iPhone OS normally launch in portrait mode to match the orientation of the Home screen. If you have an application that runs in both portrait and landscape modes, your application should always launch in portrait mode initially and then let its view controllers rotate the interface as needed based on the device’s orientation. If your application runs in landscape mode only, however, you must perform the following steps to make it launch in a landscape orientation initially.

  • In your application’s Info.plist file, add the UIInterfaceOrientation
    key and set its value to the
    landscape mode. For landscape
    orientations, you can set the value
    of this key to
    UIInterfaceOrientationLandscapeLeft
    or
    UIInterfaceOrientationLandscapeRight.

  • Lay out your views in landscape mode and make sure that their autoresizing options are set correctly.

  • Override your view controller’s shouldAutorotateToInterfaceOrientation: method and return YES only for the
    desired landscape orientation and NO
    for portrait orientations.

like image 91
Justin Gregoire Avatar answered Oct 07 '22 12:10

Justin Gregoire


To make your app landscape mode only, you should use "Supported Interface Orientations". (Targets -> YourApp -> Supported Interface Orientations -> Landscape Left & Right)

Supported Interface Orientations

You should also set the app's orientation in your app's Info.plist file (Info.plist file) by appending the Supported interface orientations key with the values Landscape (left home button) and Landscape (right home button). row's

You may use willRotateToInterfaceOrientation and/or didRotateFromInterfaceOrientation to handle orientation changes.


shouldAutorotateToInterfaceOrientation is deprecated from iOS 6 and out.

Returning UIDeviceOrientationLandscapeLeft/Right for shouldAutorotateToInterfaceOrientation should make your app "landscape":

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {     return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); } 

Also may also change your app's Info.plist and View Orientation (as explained above).


Additionally, I recommend changing your view's orientation to Landscape in the Attributes Inspector. landscape

like image 41
Aleksander Azizi Avatar answered Oct 07 '22 11:10

Aleksander Azizi