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

Som*_*ser 4 iphone xcode ios ios11 arkit

对于iOS 11的测试版,即使使用与旧设备兼容的3DOF,ARKit应用程序也会崩溃?

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

Vas*_*vev 10

支持的设备

从iOS 11开始,您无法在旧设备上使用ARKit:

重要

ARKit需要具有A9或更高版本处理器的iOS设备.

要使您的应用仅在支持ARKit的设备上可用,请使用应用的Info.plist的UIRequiredDeviceCapabilities部分中的arkit密钥.如果增强现实是应用程序的辅助功能,请使用isSupported属性确定当前设备是否支持您要使用的会话配置.

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

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

防止崩溃

要防止应用程序崩溃,您可以使用isSupported属性ARConfiguration.别忘了检查当前的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.
}
Run Code Online (Sandbox Code Playgroud)

在尝试创建AR配置之前,请通过检查相应配置类的isSupported属性来验证用户的设备是否支持您计划使用的配置.如果此属性的值为false,则当前设备不支持所请求的配置.

  • @SomeUser这就是苹果在他们的文档中所说的:https://developer.apple.com/documentation/arkit (2认同)
  • 请注意,Apple的AR Kit是[购买Metaio](https://www.recode.net/2015/5/29/11563122/apple-buys-german-augmented-reality-software-maker-metaio)的结果,其中SDK*在旧设备上运行*[运行正常](https://www.theverge.com/2015/5/28/8682505/apple-acquires-metaio-augmented-reality-startup),如果你能得到它的话了.事实上,我在一个使用Metaio制作[this](https://vimeo.com/194551673)的团队工作,正如您所看到的,在旧硬件上工作正常. (2认同)