2012-06-12 54 views
4

我有一個(簡單)網頁打包在phonegap應用程序中。如果我啓動應用程序,它會以橫向頁面寬度的縱向顯示頁面。所以文本從左下到左上開始。在右側,我有一個頁面應該結束的差距。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我鎖定屏幕旋轉。發佈圖像在橫向上顯示正確。

該頁面旨在適合具有固定尺寸的景觀。這是我的觀點:

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

並且該頁面具有正確的橫向寬度,但已轉向。我可以上下滾動。應用程序啓動後,ipad狀態欄從頂部向左跳轉。

UPDATE

我的目標設備更改爲僅允許和定向景觀只剩下現在的狀態欄上需要它是頂級的iPad。頁面仍然處於打開狀態...我也嘗試製作一個simple page version,它應該旋轉什麼也不起作用。

更新2

Classes/MainViewController.m我:

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

什麼,當你旋轉你的應用程序爲縱向發生,然後再次景觀? – Krunal

+0

檢查根控制器 - shouldAutorotateToInterfaceOrientation,如果它允許根視圖旋轉? – Tom

+0

@Tom就是這樣!你能把它作爲答案發布嗎?所以我可以給你一些聲譽。非常感謝! – PiTheNumber

回答

4

您可以檢查根CONTRO ller - shouldAutorotateToInterfaceOrientation,允許旋轉某個方向。希望能幫助到你。

例如return trueClasses/MainViewController.m

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

嘗試使用元標籤

<meta name="viewport" content="width=720,maximum-scale=1.0" /> 

和更多閱讀this page

+0

我有'width = device-width'的視口。我將它添加到我的問題。 – PiTheNumber

2

Tom的回答這個問題,我想我會分享這些重建一個應用程序使用舊版本的XCode和iOS的解決方案。我不記得我有的舊版本,但我現在使用iOS 6.1的基本SDK在XCode 4.6.1上。我確信我之前使用的是iOS 5.x的基本SDK。

我有以下行替換它:

[self.window addSubview:self.viewController.view]; 

...與下面的線,方向修正:

self.window.rootViewController = self.viewController; 
相關問題