【发布时间】:2012-03-04 03:37:36
【问题描述】:
为了节省电量,我会监控位置更新以查看用户是否已经静止了一段时间;如果是这样,我将 CLLocationManager 从其主要设置 kCLLocationAccuracyBestForNavigation 和 kCLDistanceFilterNone(最大设置)降级为仅监控重大位置变化。
问题是,它不起作用:在调用 startMonitoringSignificantLocationChanges 之后,位置更新继续以高速率涌入,就像调用之前一样。
你如何结束活动然后再次备份?
更新:这段代码回答了这个问题:
//Set
if ( shouldMonitorSignificantChangeUpdates ) {
NSLog(@"Entering -> significant change mode");
[self.locationManager stopUpdatingLocation];
[self.locationManager startMonitoringSignificantLocationChanges]; //aka stop monitoring every location change
} else {
NSLog(@"Exiting <- significant change mode");
[self.locationManager stopMonitoringSignificantLocationChanges]; //aka begin monitoring every location change
[self.locationManager startUpdatingLocation];
}
【问题讨论】:
-
你如何测试这个?通过记录设备通过检测蜂窝塔 ID (GSM) 的变化来确定存在显着的位置变化。也可以查看stackoverflow.com/questions/8290707/…
-
是的,看来我没有让塔改变,所以从来没有得到更新,错误地假设整个系统都被禁用了。
标签: iphone core-location