繁体   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