簡體   English   中英

如果iOS和設備低於iOS11和iPhone 8,則提示用戶使用UIAlertController?

[英]prompt the user using a UIAlertController if iOS and device lower than iOS11 and iphone 8?

如果用戶在低於iPhone 8和低於iOS 11的iOS版本的設備中安裝應用程序,則會彈出UI警報“使用該應用程序的最低要求是iOS 11和iPhone 8或更高版本”,並且有一個確定按鈕。 我想告訴用戶,不支持他們的設備。 這是代碼中的內容。

注意:我確實將部署目標設置為iOS11,但是如何為設備iPhone8設置它?

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()       
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        let alertController = UIAlertController(title: "Foo", message: "Bar", preferredStyle: .alert)

        alertController.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
        // check
        if #available(iOS 11.0,*)
        {

        }
        else
        {
            present(alertController, animated: true, completion: nil)
        }       
    }
}

您可以在info.plist要求設備支持nfc

每個Apple: https//developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/DeviceCompatibilityMatrix/DeviceCompatibilityMatrix.html

  • nfc需要使用iPhone 7或更高版本,並且所有iPad均不支持nfc

在此處輸入圖片說明

在此處輸入圖片說明

如果您確實(確實)確實希望在運行時限制對iPhone 8的應用程序使用,則可以從SO Answer中讀取對UIDevice進行此擴展的設備模型。

注意,Apple可能不會-或很可能不會-讓您將應用發布到AppStore。 極力避免通過代碼殺死應用!! 僅顯示警報,您的應用程序不旨在在iPhone 8以外的任何設備上運行。

暫無
暫無

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

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