如何在较旧的iOS设备上使用ARKit?

前端之家收集整理的这篇文章主要介绍了如何在较旧的iOS设备上使用ARKit?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
对于iOS 11的测试版,即使使用与旧设备兼容的3DOF,ARKit应用程序也会崩溃?

如果不支持ARKit,我该如何防止应用程序崩溃?

解决方法

支持的设备

从iOS 11开始,can’t在旧设备上使用ARKit:

Important

ARKit requires an iOS device with an A9 or later processor.

To make your app available only on devices supporting ARKit,use the
arkit key in the UIrequiredDeviceCapabilities section of your app’s
Info.plist. If augmented reality is a secondary feature of your app,
use the isSupported property to determine whether the current device
supports the session configuration you want to use.

设备应具有A9或更高版本的处理器.您只能使用:

> iPhone SE,
> iPhone 6S及更新版(7,8,X),
> iPad(2017)或更新版本,
> iPad Pro(任何).

防止崩溃

要防止应用程序崩溃,您可以使用ARConfiguration的isSupported属性.别忘了检查当前的iOS版本.

import ARKit

func isARSupported() -> Bool {
    guard #available(iOS 11.0,*) else {
        return false
    }
    return ARConfiguration.isSupported
}

if isARSupported() {
    // ARKit is supported. Do what you need.
} else {
    // ARKit is not supported.
}

Before attempting to create an AR configuration,verify that the user’s device supports the configuration you plan to use by checking the isSupported property of the corresponding configuration class. If this property’s value is false,the current device does not support the requested configuration.

猜你在找的Xcode相关文章