2012-01-04 46 views
1

這可能是幾個線程的重複,但我發現解決此問題的解決方案對我無效。我的應用程序總是開始在縱向模式下,即使我有我的APP-Info.plist中的下一行:iPad應用程序始終以肖像模式啓動

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

感謝您幫助

[編輯1]爲了這個問題更清楚

應用程序實際上是在橫向模式下啓動的,但是當我在rootViewController的viewDidLoad方法中記錄屏幕大小時,它給了我縱向模式的大小。這是實際的問題,因爲我想添加一個子視圖到主視圖,其大小取決於屏幕的方向。我希望我更清楚。

回答

3

您的AppDelegate具有shouldAutorotateToInterfaceOrientation:方法。如果它返回YES,那麼任何方向都將被允許。 試試這個:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ 
    // Returns only Landscape Mode 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
} 

希望這有助於

+1

它仍然無法正常工作。當我在橫向模式下啓動應用程序並在viewDidLoad方法中記錄屏幕大小時,它會給我WIDTH:768.000000/HEIGHT:1004.000000 ... – 2012-01-04 09:21:25

+0

+1爲我工作,謝謝! – Jasper 2013-03-06 09:07:13

+0

但不是在iOS5中,雖然 – Jasper 2013-03-06 09:22:29

0

確保你沒有手動旋轉的UIView,如果在廈門國際銀行沒有檢查,尺寸檢查的屬性(我可旋轉但不能適應新的大小)

+1

尺寸取決於在視圖的屬性檢查器中設置的方向。但我不想將其設置爲橫向或縱向。我希望該應用能夠檢測iPad的方向。 – 2012-01-04 10:34:29

+0

你在ViewWillAppear方法上得到了同樣的結果嗎? – amir 2012-01-04 13:57:38

0

我有同樣的問題,這個解決它,我:

self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 
相關問題