我使用NavigationController来显示用户可用的地理围栏列表。在顶部有一个全局开/关开关,我想用它来禁用任何注册到CoreLocation -startMonitoringForRegion的围栏。
我的栅栏似乎可以正常工作,但无论我单独禁用栅栏多少次,我仍然得到紫色的位置箭头,表明系统仍在监控我的位置和/或栅栏。
当我单独禁用我的栅栏时,我就是这样做的。
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];,但它只返回活动的栅栏,而且仅当我加载了详细信息视图时才返回。我不能在我的程序中调用它的任何其他地方,并让它返回我的任何栅栏,即使我知道它们应该是活动的。如果有人有任何建议下一步去哪里,我洗耳恭听。
发布于 2012-07-03 09:49:08
或者,一个更简单的解决方案:
for (CLRegion *monitored in [locationManager monitoredRegions])
[locationManager stopMonitoringForRegion:monitored];发布于 2011-08-26 05:07:27
好了,我想我终于可以回答我自己的问题了。这是否意味着我可以索要我自己的赏金?
首先,挥之不去的位置箭头似乎是一个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]];
}我能够显示我的数组,并证明它们都在那里。删除后的另一次检查显示它们都不见了。呼!!位置箭头的问题仍然存在,具体取决于您运行的iOS版本。我想我不能那样做。如果你有用户,确保你告诉他们紫色箭头不是你的错。关于这个问题的更多信息,你可以从这里开始。GetSatisfaction祝你好运。
发布于 2011-08-26 10:17:38
是的,这是一个iOS错误。删除并重新安装应用程序没有帮助。我设法摆脱这个问题的唯一方法是重置位置警告
https://stackoverflow.com/questions/7061007
复制相似问题