html - Phonegap 页面旋转错误,在横向模式下显示为纵向

标签 html ipad cordova screen-orientation

我有一个(简单的)网页打包在一个 phonegap 应用程序中。如果我启动该应用程序,它会以横向页面宽度纵向显示页面。所以文本从左下开始到左上。在右边我有一个页面应该结束的地方。

这是我看到的:

enter image description here

在我的 ...-Info.plist 中,支持的方向是左右横向:

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
    <string>UIInterfaceOrientationLandscapeRight</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
</array>

在我的 iPad 上,我锁定了屏幕旋转。启动图像在横向显示正确。

页面设计为适合固定尺寸的横向。这是我的视口(viewport):

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

并且该页面具有正确的横向宽度,但它被翻转了。我可以上下滚动。 app启动后ipad状态栏从顶部跳到左边。

更新

我将目标设备更改为仅 iPad,并且仅允许向左横向方向,现在状态栏位于顶部需要的位置。页面还在翻……我也试过做一个simple page version那应该旋转也不起作用的东西。

更新 2

Classes/MainViewController.m 我有:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

最佳答案

您可以检查根 Controller - shouldAutorotateToInterfaceOrientation,允许特定方向的旋转。希望对您有所帮助。

例如 Classes/MainViewController.m 中的return true:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    //return (interfaceOrientation == UIInterfaceOrientationPortrait);
    return true;
}

关于html - Phonegap 页面旋转错误,在横向模式下显示为纵向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10996676/

相关文章:

iphone - 从 iOS 应用程序开发转向 Mac 应用程序开发时需要克服的最大障碍是什么?

java - 未从 cordova apk 加载 native 库

ios - Phonegap框架中封装的Flash

html - 文本对齐 : right; not working for <label>

iphone - objective-c : Using UIImage for Stroking

iphone - 安装 Xcode 4.2 后,命令/usr/bin/codesign 失败,退出代码为 1

javascript - 无法在 Ionic Framework 上使用 Crosswalk 获取地理定位(未发现错误)

javascript - JQuery 获取返回未定义的数据属性

html - 使文本远离页面的左上角

html - 替换网站移动版本中的图标