簡體   English   中英

嘗試以橫向檢測iPhone 6 Plus

[英]Trying to detect iPhone 6 Plus in landscape orientation

我的應用今天有一個小部件,並且已經在代碼中設置了對象的布局(不使用自動布局),但是,我需要檢測用戶何時使用iPhone 6 Plus。 這樣做的原因是因為在6 Plus的通知中心中,邊緣周圍有一個邊框,該邊框切斷了我的小部件(橫向)中的標簽。

問題是我一直在試圖找出屏幕在橫向上的高度值時遇到問題。

這是我現在擁有的代碼:

        var height = UIScreen.mainScreen().bounds.size.height

    if UIDevice.currentDevice().orientation.isLandscape && height == 414 {
        totalBudgetDisplay.frame.origin.x = UIScreen.mainScreen().bounds.width - 250
        currentBudgetDisplay.frame.origin.x = UIScreen.mainScreen().bounds.width - 250
        budgetNameDisplay.frame.origin.x = 80
        warningLabel.center = view.center
        button.frame = CGRectMake(0, 0, view.bounds.width, view.bounds.height)
    }

這是橫向屏幕高度的正確值嗎? 如果是這樣,為什么標簽仍然沒有移動?

您的代碼不錯,但是UIDevice.currentDevice()。orientation.isLandscape只是無法為您提供正確的值。

好像沒有防彈解決方案來檢測擴展的設備方向。

查看此答案以獲取可能的解決方法-https: //stackoverflow.com/a/26023538/2797141

暫無
暫無

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

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