【发布时间】:2011-02-09 09:22:27
【问题描述】:
我一直在尝试寻找任何方法来优化基于位置的 iPhone 应用程序的性能,并且看到有人提到您可以通过启动和停止 CLLocationManager 来强制更新位置。我需要我能获得的最佳准确度,而在我的情况下,用户可能希望在他们四处走动时每隔几秒(比如 10 秒)看到一次更新。我已经相应地设置了过滤器,但我注意到有时我在很长一段时间内都没有在设备上获得任何更新。
我正在测试以下方法,它会在固定时间间隔过去时强制更新(我使用的是 20 秒)。我的直觉告诉我,这确实无法帮助我向用户提供更准确的更新,而让 CLLocationManager 一直运行可能是最好的方法。
- (void)forceLocationUpdate {
[[LocationManager locationManager] stopUpdates];
[[LocationManager locationManager] startUpdates];
[self performSelector:@selector(forceLocationUpdate) withObject:nil afterDelay:20.0];
}
我的问题是 - 从 CLLocationManager 强制更新真的可以提高核心位置性能吗?会影响性能吗?如果我在 GPS 接收良好的开阔场地外,这会有帮助吗?有没有人尝试过这个?
提前致谢, 史蒂夫
【问题讨论】:
-
在设置您的 CLLocationManager 时,您应该将您的
desiredAccuracy标准设置为 `kCLLocationAccuracyBestForNavigation',在 iOS 4+ 中可用。然后,让操作系统优化。
标签: iphone gps cllocationmanager core-location