gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 07:56:52 25 4
gpt4 key购买 nike

我正在使用 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 的 Apple 文档和这些方法的使用,但我已无路可走。

我试过调用 [locationManager monitoredRegions]; 但它只返回事件围栏,并且只有在我加载详细 View 时才返回。我无法在我的程序中的任何其他地方调用它并让它返回我的任何栅栏,即使我知道它们应该处于事件状态。如果有人对下一步有任何建议,我会洗耳恭听。

最佳答案

或者,一个更简单的解决方案:

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

关于iphone - 如何禁用使用 -startMonitoringForRegion 注册的任何 CLRegion 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7061007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com