Pro*_*... 0 iphone xcode map ipad ios
我正在制作一个跟踪用户的应用程序.我注意到当应用程序进入后台时,然后当你打开应用程序时,它会向用户显示错误的当前位置,直到大约5秒钟.有没有解决这个问题,因为5秒的延迟会破坏跟踪结果(它会毫无理由地增加三英里).
编辑:问题实际上不是"错误".我必须在我的Info.plist中设置我想要后台处理和繁荣的应用程序跟踪是超级准确的.一个小教程:
您可以做的一件事就是检查您要归还的horizontalAccuracy
财产CLLocation
.如果这超过某个阈值,那么您可以丢弃结果并等待更准确的结果.如果它是数英里外,那么我预计准确度数字会非常大.它最有可能使用一个小区站点来确定位置而不是GPS,并且误差幅度会大得多.
在你CLLocationManagerDelegate
的locationManager:didUpdateLocations:
方法中你可以做到以下几点:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
if ([locations count] > 0) {
CLLocation *lastUpdatedLocation = [locations lastObject];
CLLocationAccuracy desiredAccuracy = 1000; // 1km accuracy
if (lastUpdatedLocation.horizontalAccuracy > desiredAccuracy) {
// This location is inaccurate. Throw it away and wait for the next call to the delegate.
return;
}
// This is where you do something with your location that's accurate enough.
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1948 次 |
最近记录: |