It is possible to lock the app orientation permanently by editing the config.xml for iOS devices.
That doesnt seem to work if I want to set iPad and iPhone to behave differently.
Can I do it separately in the app by using function platform.is?
if (this.platform.is('ipad')) {
// do not lock orientation
}
if (this.platform.is('iphone')) {
// lock orientation
}
You can’t lock the screen orientation for specific devices in the config.xml. You’ll have to do it in the app.ts/js file. Here a TypeScript example:
platform.ready().then(() => {
if (platform.is('ipad')) {
screen.lockOrientation('portrait');
} else if (platform.is('iphone')) {
screen.lockOrientation('portrait');
} else if (platform.is('android')) {
screen.lockOrientation('portrait');
} else {
screen.lockOrientation('portrait');
}
});
Actually you can lock screen orientation for your iOS app in config.xml. Use this plugin:
And add the following to the <platform name=“ios”> section of your config.xml:
<config-file parent=“UISupportedInterfaceOrientations” platform=“ios” target="-Info.plist">
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
</config-file>
<config-file parent=“UISupportedInterfaceOrientations~ipad” platform=“ios” target="-Info.plist">
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</config-file>
hi is this screen.lockOrientation an ionic 2 function? cuz I didnt find it in the ionic2 nor the Angular 2 Doc.
Nope, it belongs to this plugin: