CLLocation始终在iPad(仅Wifi)上返回速度-1,但在iPhone上工作正常

时间:2018-10-04 11:19:40

标签: ios swift ipad cllocationmanager cllocation

我正在尝试使用CLLocation在iPad上加快速度,但它给了我-1,并且在iPhone上完美运行

我浏览过Apple文档,说负速度无效,可以忽略。

使用的设备:iPad Mini 4 操作系统:11.4.1(15G77)

 driver.findElement(By.xpath("//img[@alt='145.36KB File Size']")).click();

1 个答案:

答案 0 :(得分:0)

负值表示无效速度。大多数情况下,这是当您在建筑物内时发生的,并且由于建筑物的缘故,您的位置经常移动。

一个简单的解决方法是:

let userLocation: CLLocation = locations[0]
var speed: CLLocationSpeed = CLLocationSpeed()
speed = (locationManager.location?.speed)!
 if speed < 0 { 
    speed = 0 
 }
SpeedLabel.text = String(format: "%.0f km/h", speed * 3.6)