【问题标题】:startMonitoringSignificantLocationChanges Delegate only called oncestartMonitoringSignificantLocationChanges 委托只调用一次
【发布时间】:2016-05-30 19:04:58
【问题描述】:

我对 startMonitoringSignificantLocationChanges 有疑问。如果我为我的 locationManager 调用此方法,则 locationManager:didUpdateLocations: 方法只调用一次。现在,如果我在模拟器中启动一个驱动器(如 here 所述 - 调试 -> 位置 -> 高速公路驱动器),它将不再被调用。 Apple 规定应该每 500m 甚至每 5 到 15 分钟调用一次。我等了又等,没有成功。

这是小代码,我也做了一个Github minimal example。当然错误方法也永远不会被调用。它没有在汽车的真实设备上进行测试,因为我认为它应该首先在模拟器中工作。我在这里错过了什么?

- (void)viewDidLoad {
    [super viewDidLoad];

    if(self.locationManager == nil){
        self.locationManager = [[CLLocationManager alloc] init];
    }

    // Set the delegate
    self.locationManager.delegate = self;
    [self.locationManager requestAlwaysAuthorization];

    [self.locationManager startMonitoringSignificantLocationChanges];

}

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
    CLLocation *currentLoc = [locations lastObject];
    NSLog(@"New Location: %f/%f, Locations: %lu", currentLoc.coordinate.latitude, currentLoc.coordinate.longitude,(unsigned long)[locations count]);
}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
    NSLog(@"Loc Error: %@", [error userInfo]);
}

【问题讨论】:

    标签: ios location cllocationmanager


    【解决方案1】:

    好的,我刚刚从 Github 下载了我自己的最小项目,并在 iPhone 5S 模拟器上进行了尝试。它在那里工作。之前我只用 6S 尝试过,但它没有用。现在将在设备 6(S) 上试用,希望也能在那里工作..

    但也许会在不久的将来帮助某人:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多