20

I didn't have this problem on previous versions of Phonegap. But in 2.2, when I change the orientation, it doesn't update the uiwebview.

Does phonegap not support landscape view by default? How do you handle this?

problem

noway
  • 2,585
  • 7
  • 41
  • 61

4 Answers4

50

This is not an issue with the WebView getting updated but with the meta tag in the index.html's document head.

<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />

After removing the unnecessary height=device-height everything works just fine

<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-densitydpi=device-dpi" />

landscape is supported

  • 1
    Thank you so much, height=device-height was working (wasn't hurting) on Android, after deleting it for iOs I re-tested with android and saw it was unnecessary in the first place, so a great solution – Kaan Soral Mar 23 '13 at 18:32
  • 1
    Yes but if you remove height=device-height you get problems with the keyboard covering the screen. – rich97 Apr 08 '14 at 11:23
4

To add to Stephan's answer, if you need to do anything special when the orientation changes, you can set a callback function to:

window.onorientationchange

Adam Lockhart
  • 1,165
  • 1
  • 10
  • 13
3

I have also have same issue in ios phonegap ....

Just go and update x-code project file (IOS Application target ) change or update support interface orientation and check it all orientation .

it's work well ...

  • Yep this was it. in Xcode Targets-> Your App -> iPhone/iPad Deployment Info -> "Supported Interface Orientations". Click each orientation you wish to support. By default it seems only Portrait is enabled. – notacouch Sep 09 '13 at 17:01
  • code-wise these options sit in `platforms/ios/appname/appname-Info.plist`, `UISupportedInterfaceOrientations UIInterfaceConstant ` replace string `UIInterfaceConstant` with any of [these constants](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/c/tdef/UIInterfaceOrientation) (so one string element per supported orientation). For iPad it's the same thing but the key is `UISupportedInterfaceOrientations~ipad`. – notacouch Sep 11 '13 at 15:30
2
window.addEventListener(
    "orientationchange",
    function() {
        // Announce the new orientation number
        location.reload();
    }, false );