gpt4 book ai didi

iphone - stopMonitoringForRegion with dummy lat long but the right "identifier"

转载 作者:太空狗 更新时间:2023-10-30 04:01:13 24 4
gpt4 key购买 nike

我正在我的应用程序中安排和取消区域监控,如下所示。

- (void) setLocationReminderForLatitude:(double) latitude longitude:(double) longitude radiusInMetres:(double) radius withIdentifier:(NSString *) identifier
{
CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:CLLocationCoordinate2DMake(latitude, longitude) radius:radius identifier:identifier];
[coreLocation startMonitoringForRegion:region desiredAccuracy:50]; //50 metres
}

- (void) cancelLocationNotification:(NSString *)identifier
{
CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:CLLocationCoordinate2DMake(0.0, 0.0) radius:100.0 identifier:identifer];
[coreLocation stopMonitoringForRegion:region];
}

取消区域监控时,我可能不一定有我最初用来开始监控该区域的中心和半径信息,但标识符是正确的。这行得通吗?

文档没有提及任何相关内容。

最佳答案

您需要拉取正确的区域以禁用监控。我要做的是遍历所有启用的区域,然后停止监视与您的标识符匹配的区域。

for (CLRegion *region in [locationController.locationManager monitoredRegions]) {
if (region.identifier isEqual:yourIdentifier]) { // change this to match your identifier format
[locationController.locationManager stopMonitoringForRegion:region];
}
}

关于iphone - stopMonitoringForRegion with dummy lat long but the right "identifier",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11388961/

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