I have an iPad app for iOS which I would like to work in both portrait and landscape mode but I have narrowed the issue down to being a problem specifically with landscape mode.
In the settings in xcode I have the device orientation set as follows (I realise these are connected to the orientation setting in config.xml but its quicker to debug directly in xcode):
If I rotate the device to portrait and then back to landscape, it corrects itself but obviously this is undesirable.
I have trawled the forums/google and have seen quite a few similar problems like this and this but have not seen a satisfactory solution.
Some info about my setup:
Latest Ionic 1.2.0
Ionic CLI 1.7.11
Cordova ios 3.9.2
Cordova CLI 5.4.1
I’m on a mac (osX 10.10.3) running xcode 6.4
Testing app on an iPad Mini (ios 8.1.2) but problem is also happening on an ipad air running ios 8.3
My viewport meta tag looks like <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> but I have tried with a few variations and even no meta tag but it has no effect.
I have tried lots of different variations of <preference name="Orientation" value="landscape" /> and <preference name="Orientation" value="default" /> and <preference name="Orientation" value="all" /> in the config.xml.
The best solution I have got at the moment (Which @Gajotres suggested here) is to omit the <preference name="Orientation" /> tag completely and use the cordova screenorientation plugin to unlock the orientation. BUT there is one problem with this…
Now when I launch the device in landscape mode, although it fixes the weird cut-off effect. The app still seems to think it’s in portrait mode (i.e. same as previous screenshot, just without the black border and the buttons are further along to edge of the screen). I have to rotate the device to portrait and then back to landscape mode and it then corrects itself. Again not desirable.
I have been wrestling with this for quite a while now and don’t know where to go with this issue. I find it a bit strange that there is such a glaring problem with a supposedly trivial task of launching an ipad app in landscape mode which makes me think that I must be doing something wrong but it seems quite a few other people are having the same issue so I don’t know what to think.
It works beautifully. Again, take this with a grain of salt, I don’t know what unintended consequences it will have, but I haven’t found any so far.
Off the back of that discussion, I am now using this forked plugin instead of the official cordova plugin until they fix the issue. The forked version comments out a whole block of code in the load method but it seems to be interconnected to your solution.
I still think there may be an issue with iPhone (especially iPhone 6 plus) in landscape mode, even with this workaround, but I need to fully device test before coming to any conclusions.
In case you haven’t seen, this was fixed in the official plugin about a week after we had this conversation, lol. The exact issue was that when number was nil, it should return YES, and as we know, it wasn’t.
Had tried to delete <preference name="Orientation" /> and used only plugin to control the orientations, later tried to set the orientation to the Landscape, neither methods had work. Also tried the work around from elli_wodify but the problem still occurred.