PhoneGap页面旋转错误,以横向模式显示为纵向 [英] Phonegap page has wrong rotation, shows as portrait in landscape mode
问题描述
我有一个(简单的)网页包装在phonegap应用程序。如果我启动该应用程序,它显示页面纵向方向与横向页面宽度。所以文本从左下到左上。
这是我所看到的:
img src =https://i.stack.imgur.com/tCLPo.pngalt =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上,我锁定了屏幕旋转。启动图片在横向显示正确。
页面设计适合固定尺寸的风景。这是我的视口:
< meta name =viewportcontent =width = device-width,initial-scale = 1,minimum-scale = 1.0,maximum-scale = 1.0,user-scalable = no/>
,页面具有正确的横向宽度,我可以上下滚动。
UPDATE
我将目标设备更改为iPad,并允许方向为向左,只有现在状态栏在需要的顶部。页面仍在转动...我还尝试简单页面版本
在 code> Classes / MainViewController.m 我有:
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
//对于支持的方向返回YES
return(interfaceOrientation == UIInterfaceOrientationPortrait);
}
- shouldAutorotateToInterfaceOrientation,允许旋转某个方向。希望它帮助。
例如返回true 在
Classes / MainViewController.m
:
- (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation
{
/ /对于支持的方向返回YES
// return(interfaceOrientation == UIInterfaceOrientationPortrait);
return true;
}
I have a (simple) web page packed in a phonegap app. If I start the app it shows the page in portrait direction with landscape page width. So the text starts left bottom to left top. On the right I have a gap where the page should end.
This is what I see:
Supported orientations are landscape left and right in my ...-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>
On my iPad I locked the screen rotate. The launch image shows up correct in landscape.
The page is designed to fit into landscape with fixed sizes. This is my viewport:
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
and the page has the correct width for landscape but it is turned around. I can scroll up and down. The ipad status bar jumps from the top to the left after app start.
UPDATE
I change target device to iPad only and allowed orientation to Landscape Left only now the status bar is on the top where it needs to be. Page is still turned... I also tried to make a simple page version that should rotate what did not work either.
Update 2
In Classes/MainViewController.m
I have:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
You can check the root Controller - shouldAutorotateToInterfaceOrientation, allow rotation for certain orientation. Hope it helps.
For example return true
in Classes/MainViewController.m
:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return true;
}
这篇关于PhoneGap页面旋转错误,以横向模式显示为纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!