簡體   English   中英

Xcode 不服從設備方向

[英]Xcode not obeying device orientation

我已將設備方向設置為僅在 Xcode 中檢查“縱向”。 但是,當我在模擬器中運行我的應用程序時,它會在所有方向上旋轉。

我的 Xcode 設置

在縱向(預期)和橫向(非預期)中正確顯示

以前有人遇到過同樣的問題嗎? 謝謝

Xcode 中的“General”->“Deployment Info” UI 可能具有欺騙性。 檢查info.plist這兩個鍵:

UISupportedInterfaceOrientations

UISupportedInterfaceOrientations~ipad

我遇到了同樣的問題(在物理設備中)。 在 iPhone 上它工作正常,但在 iPad 上它不起作用。 解決方案是調整兩者的“設備”選項,在這種情況下是“橫向權利”。 在“部署信息”下方的“設備方向”下選中“橫向右側”復選框

我有同樣的問題,花了我一整天的時間,我通過這樣做解決了:覆蓋 AppDelegate 方法

    func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
        

        if self.allowOrentitaionRotation {
            return .allButUpsideDown;
        }
        return .portrait;
    }

就我而言(Xcode 13.1),它非常適合我:

請按照以下步驟操作:

  1. 選擇你的目標;
  2. 選擇Build Settings
  3. 選擇AllCombined選項;
  4. 搜索orientation關鍵詞
  5. 注意Supported interface Orientations(iPhone) ,點擊右邊的值;
  6. 刪除您不想要的方向。

也許 Xcode 14 修復了這個錯誤,現在可以在 iPhone 和 iPad 上配置設備方向: 在此處輸入圖像描述

暫無
暫無

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

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