gpt4 book ai didi

ios - 您可以使用 CLLocationManager 阻止区域在两次启动之间持续存在吗?

转载 作者:可可西里 更新时间:2023-11-01 04:38:47 25 4
gpt4 key购买 nike

有没有办法阻止 CLLocationManager 在启动之间保留受监控的区域?每次启动应用程序时,我都需要添加一组新的受监控区域,旧的区域不再有用。有没有办法在启动时阻止它们持续存在或清除所有旧的?

最佳答案

当然你可以清除所有当前监控的区域:

+(void)clearRegionWatch
{
for(CLRegion *region in [[WGLocation shared].locationManager monitoredRegions]){
[[WGLocation shared].locationManager stopMonitoringForRegion:region];
}
}

如果您有想要删除的特定标识符:

+(void)clearRegionWatchForKey:(NSString *)key
{
for(CLRegion *region in [[WGLocation shared].locationManager monitoredRegions]){
if([region.identifier isEqualToString:key]){
[[WGLocation shared].locationManager stopMonitoringForRegion:region];
}
}
}

您可以将函数的内部结构复制到应用程序中的适当位置。我已经从我的共享管理器类中复制了它们。

关于ios - 您可以使用 CLLocationManager 阻止区域在两次启动之间持续存在吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25148954/

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