如果用户启用了位置服务,我将我的 RootController 分配为其委托:
appDelegate.clLocationManager.delegate = self;
其中 appDelegate 是我的应用程序委托的一个实例,这是我拥有位置服务实例的地方。clLocationManager 是 CLLocationManager 的一个实例。如果我发现用户不在某个区域,我想禁用位置服务委托。我这样做:
appDelegate.clLocationManager.delegate = nil;
但是这种方法仍然会触发:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
是否有其他方法可以禁用位置服务或至少阻止其方法触发?