如何禁用任何注册了-startMonitoringForRegion的CLRegion对象?

我正在使用NavigationController来显示用户可用的地理围栏列表。 在顶部有一个全局开关,我想用来禁用CoreLocation -startMonitoringForRegion注册的所有防护。

我的篱笆似乎很好,并且大部分都在工作,但是无论我个别禁用篱笆多less次,我仍然会看到紫色的位置箭头,表示系统仍在监视我的位置和/或围栏。

当我单独禁用我的篱笆时,这就是我正在做的事情。

CLLocationCoordinate2D coord; coord.latitude = [[settingsData valueForKey:@"latitude"] doubleValue]; coord.longitude = [[settingsData valueForKey:@"longitude"] doubleValue]; CLLocationDistance radius = [[settingsData valueForKey:@"radius"] intValue]; CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:coord radius:radius identifier:[settingsData valueForKey:@"name"]]; // remove this fence from system monitoring [locationManager stopMonitoringForRegion:region]; [region release]; 

我已经浏览了苹果关于CoreLocation的所有文档以及这些方法的使用,而且我已经走到了尽头。

我试过调用[locationManager monitoredRegions]; 但它只返回活动的栅栏,只有当我有我的细节视图加载。 我不能在我的程序中调用任何其他地方,并让它返回我的任何围栏,即使我知道他们应该积极。 如果任何人有任何build议去下一个,我都耳朵。

或者,更简单的解决scheme:

 for (CLRegion *monitored in [locationManager monitoredRegions]) [locationManager stopMonitoringForRegion:monitored]; 

好的,我想最后我可以在这里回答我自己的问题。 这是否意味着我可以要求自己的赏金? :d

首先,徘徊的位置箭头似乎是一个iOS的错误。 我发现了很多同样的问题。 所以我现在不会做太多的事情。

就一次去除我所有的区域而言,我现在得到了这一点。

 NSArray *regionArray = [[locationManager monitoredRegions] allObjects]; // the all objects is the key for (int i = 0; i < [regionArray count]; i++) { // loop through array of regions turning them off [locationManager stopMonitoringForRegion:[regionArray objectAtIndex:i]]; } 

我能够展示我的arrays,并certificate他们都在那里。 去除后的另一个检查显示他们都没有了。 呼! 位置箭头的问题依赖于您正在运行的iOS版本。 我猜不出来。 如果你有用户,确保你通知他们紫色箭头不是你的错。 欲了解更多关于这个问题的信息,你可以从这里开始。 GetSatisfaction祝你好运。

是的,这是一个iOS的错误。 删除并重新安装应用程序没有帮助。 我设法摆脱这个问题的唯一方法是重置位置警告