【发布时间】:2011-03-31 12:08:56
【问题描述】:
我正在编写一个使用 GPS 数据的 iPhone 应用程序。我的问题是 GPS 永远不会停止更新位置(箭头停留在状态栏上),即使我终止了实际进程。使其消失的唯一方法是卸载该应用,或在系统设置中禁止其使用位置信息。
这就是我创建位置管理器的方式:
// Create the location manager if this object does not
// already have one.
if (nil == locationManager)
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = regionTracker;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
// Set a movement threshold for new events.
locationManager.distanceFilter = 1;
[locationManager startUpdatingLocation];
在我的应用委托中,我在 applicationWillTerminate: 和 applicationDidEnterBackground: 中运行这两行
[self.viewController.locationManager stopUpdatingLocation];
[self.viewController.locationManager setDelegate:nil];
我 nil 代表是因为我看到了他们这样做的一些例子,但真的需要吗?
【问题讨论】:
-
locationManager 属性是否在这些应用程序委托方法中提供非零值?
-
是的。我只是测试了一个断点,如果它是零,没有骰子。感谢您提供更多帮助!
标签: iphone objective-c ios4