我目前正在尝试制作一个 iOS 版本的 Android 应用程序,它会收集传感器数据。我在 Swift 中获取接近传感器的特定值时遇到问题。
Android 中的 TYPE_PROXIMITY
以 cm 为单位返回距对象距离的 int 类型值,而 Swift 的 CLProximity
仅返回枚举值,表明距离是远还是近。
我很确定肯定还有一种方法可以在 Swift 中获取特定值,因为它在 Android 中可用...但我找不到方法。
参考:
https://developer.android.com/reference/android/hardware/Sensor#TYPE_PROXIMITY https://developer.apple.com/documentation/corelocation/clproximity