ios位置管理器即使未命中distancefilter指定的距离也会触发
有人能告诉我为什么当我的距离过滤器设置为30米时,我每隔两步左右就会得到位置更新ios位置管理器即使未命中distancefilter指定的距离也会触发,ios,location,cllocationmanager,Ios,Location,Cllocationmanager,有人能告诉我为什么当我的距离过滤器设置为30米时,我每隔两步左右就会得到位置更新 - (void)initLocationTrackingStandard { [self.locationManager setPausesLocationUpdatesAutomatically:YES]; [self.locationManager setActivityType:CLActivityTypeOther]; [self.locationManager setDistan
- (void)initLocationTrackingStandard
{
[self.locationManager setPausesLocationUpdatesAutomatically:YES];
[self.locationManager setActivityType:CLActivityTypeOther];
[self.locationManager setDistanceFilter:30.0];
[self.locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[self.locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation* location = [locations lastObject];
NSDate* eventDate = location.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 5.0)
{
// Use location if it is within 5 seconds
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertBody = @"update location";
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];
}
}
-(无效)初始位置跟踪标准
{
[self.locationManager setPausesLocationUpdates自动:是];
[self.locationManager setActivityType:CLActivityTypeOther];
[self.locationManager setDistanceFilter:30.0];
[self.locationManager设置了所需的精度:KCallocationAccuracyNearesttenmeters];
[self.locationManager startUpdatingLocation];
}
-(无效)位置管理器:(CLLocationManager*)管理器更新位置:(NSArray*)位置
{
CLLocation*location=[locations lastObject];
NSDate*eventDate=location.timestamp;
NSTimeInterval howRecent=[eventDate timeIntervalSinceNow];
if(防抱死制动系统(最新)<5.0)
{
//如果在5秒内,则使用位置
UILocalNotification*localNotification=[[UILocalNotification alloc]init];
localNotification.alertBody=@“更新位置”;
localNotification.soundName=UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication]presentLocalNotificationNow:localNotification];
}
}
我以前只使用过kCLDistanceFilterNone,所以我不知道你看到的是正常还是不正常,但我的第一个线索与准确性有关。。这些更新的准确性如何?我会把它们记录下来进行比较。我可以想象,如果两个位置之间的距离小于30米,那么如果它们的精度都是60米左右,那么它们看起来就足够远了?