Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable landscape-orientation on an iPad app?

I created a completely new, single-view iOS universal Swift app. Then, I unchecked "Landscape Left" and "Landscape Right" in the app settings. I ran it on my iPhone, and hooray, it stays in portrait mode no matter how I rotate my phone. Then I ran it on my iPad, and it rotates to anything. Even upside-down portrait mode, which wasn't enabled in the first place? Am I the only experiencing this? This happens in the iPad simulator as well when I rotate with command+arrow key.

I also tried adding the following to ViewController.swift, and got the same result.

override func shouldAutorotate() -> Bool {     return false }  override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {     return UIInterfaceOrientationMask.Portrait } 

Is there no way to actually disable rotating away from portrait on iPad?

like image 641
Eugene Avatar asked Nov 08 '15 03:11

Eugene


People also ask

Can you force apps to rotate on iPad?

You will see below that Android apps can be forced to appear in a given orientation. However, iOS apps cannot be forced to behave this way, and it is due to the nature of how these apps are required to be designed by Apple. The only way to ensure effortless rotation is to download an app designed for the iPad.

How do you lock landscape on iPad?

If you prefer to use the side switch as a mute button, you can lock your iPad's screen orientation by holding the iPad in either landscape or portrait orientation, swiping up to open Control Center, and selecting the Orientation Lock icon.


2 Answers

Its work perfectly. Dont need to write code for it.

First select project and then go in first tab "General".

Now select "Devices" option in Deployment info section is iPad and in that down select Device orientation .. In which remove checkmark from landscape Left, Right option

After done select it back device as universal and set device orientation as portrait..mode and remove check mark from landscape mode.

Now run your app in iPad and check that things. I hope it will be resolved.

like image 135
3 revs Avatar answered Oct 14 '22 11:10

3 revs


There are separate entries in Info.plist for iPhone and iPad supported orientations.

  • iPhone = UISupportedInterfaceOrientations
  • iPad = UISupportedInterfaceOrientations~ipad

You need to modify Info.plist and remove landscape entries for UISupportedInterfaceOrientations~ipad key.

like image 33
Tomasz Czyżak Avatar answered Oct 14 '22 11:10

Tomasz Czyżak