Support different orientations on iPhone & iPad? - ios

I want to support both portrait and landscape on iPad, but only portrait on iPhone.
Is it possible? What is the best way to do this?
There's only one set of "Device orientation" checkboxes in the project settings.

You can edit the info.plist file as per your needs manually.
Notice, iPad orientation is separate from the default phone orientation.

There's only one set of "Device orientation" checkboxes in the project settings.
Yes, and you use it like this:
Check just iPhone.
Check just portrait.
Check just iPad.
Check all four orientations.
Check both iPhone and iPad.
I know it's confusing, but that will do what you want.

Related

How to make iOS app orientation portrait only?

How do I make my iOS app Portrait Only? It looks like it's already in portrait mode currently but when I flip my device it rotates still. I am using tableViews and collectionViews within my app, I'm not sure if they would affect these settings or not.
To fix this problem I had to add "Supported interface orientations (iPhone)" and set the item to "Portrait (bottom home button)" in my info.plist file

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?
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.
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.
Works for me!
Open info.plist as source code, you will see these properties:
UISupportedInterfaceOrientations : For iPhone
UISupportedInterfaceOrientations~ipad : For iPad
Under UISupportedInterfaceOrientations~ipad remove your unwanted orientation mode. In my case, I want only Portrait Mode so I removed the rest modes and then save it.
Done! Good Luck
Applies to Xcode 11, 12, 13 (Fixed in Xcode 14)
The iPhone orientation settings and iPad orientation settings can be set independently using the Deployment Info settings. No need exists to update the info.plist for orientation. Updating the Deployment Info will update info.plist for you. (This is not intuitive and may be overlooked)
For example, set the iPhone deployment info by selecting only the iPhone.
Then select the iPad deployment info by selecting only the iPad. Remove the landscape selections here.
Then when finished, if you want both iPhone and iPad settings, select them both. The settings will remain for both iPhone and iPad even if they differ (iPhone's orientation settings are shown but iPad's remain).
Flipping back to iPad only will show that the settings still remain.
The info.plist will also reflect the changes made to iPhone and iPad using the Deployment Info.
The accepted answer doesn't quite work for iOS 13 onwards, because of support for Split View.
Basically, the Supported Interface Orientations setting is ignored on iPad if you have Enable Multiple Windows set to TRUE. The rationale here is that if you are allowing your app to work in Split View then it can be squished to 'odd' dimensions which it needs to support. So by default it would need to support any orientation.
This is all a bit unintuitive, but as a result of the above, you need to set Enable Multiple Windows to FALSE in your PLIST file.
This is particularly unintuitive for iPhone-only apps because you would not unreasonably assume that the iPhone settings would carry over to iPad, providing of course that you have not set separate iPad orientation settings as other answers here have documented.
So here's a screen record of what you need to do:
Specifically:
Select iPad and deselect iPhone
Set the orientations support as required
Un-set Supports multiple windows
Switch back to iPhone only
This image is enough, only select the Portrait.
edit for Shyam's comment
Xcode8.3.3 MacOS Sierra v10.12.5
In Xcode 10 at least, for a universal app this feature is broken. For a universal app setting the orientation restriction by checking the relevant orientation only works for iPhone, you will need to go into the plist and remove the unwanted orientations under "Supported interface orientations (iPad)", where you will find all four orientations awaiting you regardless of what you checked. It's simply a bug in Xcode that apparently doesn't have a very high priority since it's been around for a while.
these process of override does not work now.. and only changing the UI supported interface oriatations for ipad in info.plist will only temporarily solve the problem but will create problem when you will go for app validation and app sumbmission to app store.. For successfully validating and submitting you have to also add the key
"UIRequiresFullScreen"
you have to modify the keys like this..
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
I have tested this...
xCode 11
project ----> General -----> Devices ---->iPad

How to make an ipad app only portrait?

I am making an ipad app, and i set the the app to only portrait, but it still works in landscape? Why is this happening only on an ipad? How do i fix this?
Note: if the answer is in code, please write it in swift.
In xcode select your project. Go to Targets -> General, scroll down and you can select the Orientation as portrait only.
You can also make change to info.plist file to select proper orientations for Supported interface orientations (iPad)
In deployment Info section you can select your app orientation to support.

IOS 8 iPad make only Launch Screen portrait only

I know how to make an iPad app portrait only for the whole app and how to make particular views portrait only, but not how to make the launch image portrait only. How do I do it?
Currently I only have "portrait" checked under "iOS 7.0 and Later" in images.xcassets. The reason I want the launch image portrait only is I tried getting landscape to work but despite multiple attempts and asking about it here, I had no luck.
Clarification:
I want the app to handle both portrait and landscape iPad and iPhone. But the landscape image for iPad does not display so I want to force the launch image and just the launch image to be Portrait only.
No idea if you checked this but here is something often overlooked.
In the Workspace, if you choose your target project, in Deployment Info, there are two things to check there. First, make sure the Device Orientation is set to "Portrait" only. Then, open the drop down menu on "Devices". Choose each separately and do the same thing. For some reason for me, universal does't apply it to iPhone and iPad simultaneously.

iPad required launch images

I'm developing a universal iOS app that only supports portrait and upside-down interface orientations. When supplying the launch images in Xcode, I see that I have warnings for landscape orientations, even having only portrait and upside down enabled in device orientations settings. Does this mean that I need to supply landscape launch images anyway? I don't find this clear in Apple's documentation.
Thanks
No. These are warnings. Apple would prefer you support all orientations on iPad, and recommend you do, but they do not require it. (Yet)
Launch Images in Landscape Orientation is optional and xCode ignores it if it is not provided in Application.
However, If you are using Xcode5 there will be a folder named Images.xcassets > Launch Images > There will be a blank icon available for iPad Landscape > Right Click on those 1x and 2x icon > Remove Selected Items.
This will remove the warnings that you are having in your case.
Let me know if that helps.
an iPad app includes at least one launch image in portrait
orientation and at least one launch image in landscape orientation.

Resources