didUpdateToLocation没有第二次调用

Fau*_*t V 3 core-location cllocationmanager cllocation ios

在我们的应用程序中,我使用CoreLocation来获取用户的位置.我认为对startUpdatingLocation的调用每次都会调用locationManager:didUpdateLocations.但是一旦它第一次被召唤,他们就再也不会被召唤了.

在我的AppDelegate.m中:

- (void) startStandardUpdates {
 if (_locationManager == nil) {
    _locationManager = [[CLLocationManager alloc] init];
    [_locationManager setDelegate:self];
    _locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    _locationManager.distanceFilter = 10;
    [_locationManager startUpdatingLocation];

 } else {
    NSLog(@"[LOCATION]: Location Manager already exists.");
    [_locationManager startUpdatingLocation];
 }
}
Run Code Online (Sandbox Code Playgroud)

然后由NSTimer调用它:

- (void) startTask {
  NSLog(@"Start task called.");
  [NSTimer scheduledTimerWithTimeInterval:15
                                   target:self
                                 selector:@selector(actualTask)
                                 userInfo:nil
                                  repeats:YES];
}

- (void) actualTask {
  NSLog(@"[TASK]: Starting location service...");
  [self startStandardUpdates];
}  
Run Code Online (Sandbox Code Playgroud)

上面的代码应该每15秒调用一次startUpdatingLocation,但是第二次没有调用didUpdateToLocation方法(第一次成功调用了...).

有没有办法以编程方式调用(或强制)didUpdateToLocation?或者我们必须等到didUpdateToLocation获取位置?我已经搜索了每隔x分钟/秒获取用户位置的方法,但似乎没有人成功实现这一点.我想做的只是Android与Service类的相关(iOS没有这个).

任何帮助,将不胜感激.
谢谢.

Aje*_*eet 5

_locationManager.distanceFilter = 10; 您的距离过滤器设置为10米,您将不会收到通知.一旦位置移动到足以超过距离过滤器设置,您将获得didUpdateToLocation回调...