簡體   English   中英

如何讓我的iPhone應用程序以橫向模式啟動?

[英]How do I get my iPhone app to start in Landscape mode?

我的應用程序已修復為橫向模式,但在viewDidLoad()甚至viewWillAppear()期間,以下縱向尺寸仍會返回:

self.view.bounds.size.width = 320.00
self.view.bounds.size.height = 480.00

直到viewDidAppear()才產生實際的景觀尺寸。

self.view.bounds.size.width = 480.00
self.view.bounds.size.height = 320.00

我發現這很奇怪。 為什么會這樣?!? 我該如何解決這個問題?

在應用程序的info.plist文件中,指定密鑰:

 UISupportedInterfaceOrientations

左,右景觀值:

在此輸入圖像描述

編輯

原始plist代碼應如下所示:

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

編輯2

您還需要此鍵來確定狀態欄的初始方向:

 <key>UIInterfaceOrientation</key>
 <string>UIInterfaceOrientationLandscapeRight</string>

此外,您需要確保所有視圖控制器(標簽欄,導航欄,常規視圖控制器)實現

 shouldAutorotateToInterfaceOrientation

並返回風景(左或右)值。

這是有關該主題的Apple文檔文章:

技術說明TN2244

最后,這是有關此主題的其他一些SO帖子: 帖子1帖子2。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM