【问题标题】:iphone - Battery using startMonitoringSignificantLocationChanges and desiredAccuracyiphone - 使用 startMonitoringSignificantLocationChanges 和 desiredAccuracy 的电池
【发布时间】:2012-03-31 11:54:24
【问题描述】:
我正在开发一个在后台运行的本地化应用程序。
我正在使用startMonitoringSignificantLocationChanges 获取用户的位置更新。
我知道这种方法只使用信号塔来确定用户位置,但它可以节省电池,即使它不是很准确。
我想知道,这种方法与desiredAccuracy或distanceFilter结合会产生什么效果?
它仍然会不准确且对电池友好吗?
或者它实际上会使用 GPS 并耗尽电池?
谢谢
【问题讨论】:
标签:
iphone
localization
power-management
【解决方案1】:
我的建议是使用两个 CCLocationManager 和委托方法
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
startMonitoringSignificantLocationChanges 的第一个,[locationManager startUpdatingLocation] 的第二个。这就是我的意思:您的主要startMonitoringSignificantLocationChanges 和不时您选择的方法调用第二个locationManager 和[locationManager startUpdatingLocation],当您获得第一个GPS 位置坐标时,您调用[locationManager stopUpdatingLocation]。这种方法是节能的,你会收到一些desiredAccuracy GPS 坐标。只需从女巫locationManager 的到来以及何时启动和停止 GPS 中处理一些个人逻辑即可。
希望你能理解我的逻辑,否则我会写一些代码。现在我不在我的 Mac 上。