簡體   English   中英

在Swift iOS9中鎖定橫向方向

[英]Lock landscape orientation in Swift iOS9

我正在努力在橫向模式下鎖定我的應用程序。 我只有一個ViewController,它不在NavigationController中。 在視圖控制器內部,我有以下代碼:

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.LandscapeLeft
}
override func shouldAutorotate() -> Bool {
    return false;
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
    return UIInterfaceOrientation.LandscapeLeft
}

在設置的“常規”選項卡中,我有以下內容:

一般

在ViewController的屬性中我有這個:

屬性

我嘗試在ViewDidLoad中使用UIDevice.currentDevice()。setValue(...),但這沒有任何效果。 我試圖在iPad mini上運行這個應用程序,我完全不知所措。 任何幫助將非常感激。

更新:我終於找到了答案。 在“Supporting Files”文件夾中,info.plist文件具有“支持的接口方向”和“支持的接口方向(iPad)”的屬性。

在此輸入圖像描述

顯然,由於我在iPad上運行應用程序,因此覆蓋了我的所有其他選擇和代碼。 刪除不需要的方向解決了我的問題。 希望這有助於某人!

暫無
暫無

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

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