Bil*_*ess 24 iphone core-location ios clregion
我正在使用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];
Run Code Online (Sandbox Code Playgroud)
我已经浏览了关于CoreLocation的所有Apple文档以及这些方法的使用,我就在最后.
我已经尝试过调用,[locationManager monitoredRegions];但它只返回活动的栅栏,并且只有在我加载了详细信息视图时.我无法在程序中的任何其他位置调用它并让它返回我的任何围栏,即使我知道它们应该是活动的.如果有人有任何建议去哪,接下来我都听见了.
the*_*boy 50
或者,一个更简单的解决方案:
for (CLRegion *monitored in [locationManager monitoredRegions])
[locationManager stopMonitoringForRegion:monitored];
Run Code Online (Sandbox Code Playgroud)
Bil*_*ess 13
好的,我想我最终可以在这里回答我自己的问题.这是否意味着我可以申请自己的赏金?: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]];
}
Run Code Online (Sandbox Code Playgroud)
我能够显示我的阵列并证明他们都在那里.移除后的另一项检查表明它们都已消失.呼!位置箭头的问题仍然取决于您运行的iOS版本.我想不出来.如果您有用户,请务必告知他们紫色箭头不是您的错.有关该问题的更多信息,您可以从这里开始.GetSatisfaction好运.
| 归档时间: |
|
| 查看次数: |
8925 次 |
| 最近记录: |