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?
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.
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.
As Siavash said, the General Tab in your Target is the best place to limit the orientations for the entire device.
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!).
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With