【发布时间】:2014-07-02 10:55:23
【问题描述】:
我正在尝试对我的位置相关应用程序实现更有效的后台处理,并在此过程中学习一些 Swift。
我注意到(很难)在第一个 Beta 版中我根本无法找到可以工作的位置,但切换到 xcode 的 Beta2 解决了这部分问题。
在我的位置处理设置中,我使用这样的代码启动 LocationManager(我希望能够切换到高分辨率,甚至以高模式启动):
locationManager.delegate = self
locationManager.distanceFilter = kCLDistanceFilterNone
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startMonitoringSignificantLocationChanges()
locationManager.startUpdatingLocation();
然后使用如下代码处理切换:
if (highResolutionSwitch.on) {
println("Switching to high resolution");
locationManager.stopMonitoringSignificantLocationChanges();
locationManager.startUpdatingLocation();
} else {
println("Switching to low resolution");
locationManager.stopUpdatingLocation();
locationManager.startMonitoringSignificantLocationChanges();
}
当处于“高”模式时,我会在 didUpdateLocations() 方法中接收位置,但在“低”模式下从不接收任何内容。
是 xcode/swift-environment 的 beta 特性还是我遗漏了什么?
【问题讨论】:
-
你是在模拟器还是真机上测试?
-
我正在测试两者。它现在可以工作了(我自己的回应)
标签: ios xcode swift location-services