gpt4 book ai didi

ios - 如何为超过 20 个区域启动 MonitoringForRegion

转载 作者:行者123 更新时间:2023-11-29 10:58:41 25 4
gpt4 key购买 nike

我正在使用它,但我不知道如何监控超过 20 个区域,因为它在 ios 中可以监控的最大区域数

if ([AllRegionsArray count] > 0) {


for (int i = 0; i < [AllRegionsArray count]; i++) {
NSArray *LongLati = [AllRegionsArray objectAtIndex:i];
lutiuid = [LongLati objectAtIndex:0];
Longtuid = [LongLati objectAtIndex:1];

CLLocationCoordinate2D centreLoc = {[lutiuid floatValue], [Longtuid floatValue]};
CLLocationDistance regionRadius = 150.00;
CLRegion *grRegion = [[CLRegion alloc] initCircularRegionWithCenter:centreLoc radius:regionRadius identifier:[NSString stringWithFormat:@"grRegion%i",i]];

[locationManager startMonitoringForRegion:grRegion desiredAccuracy:acc];

NSLog(@"Mon = %i , %i",[locationManager.monitoredRegions count],i);

}


}

最佳答案

您无法监控超过 20 个区域。也许您可以根据用户位置停止监视某些区域并开始监视其他区域(取决于您的用例)。

Discussion You must call this method once for each region you want to monitor. If an existing region with the same identifier is already being monitored by the application, the old region is replaced by the new one. The regions you add using this method are shared by all location manager objects in your application and stored in the monitoredRegions property.

Region events are delivered to the locationManager:didEnterRegion: and locationManager:didExitRegion: methods of your delegate. If there is an error, the location manager calls the locationManager:monitoringDidFailForRegion:withError: method of your delegate instead.

An app can register up to 20 regions at a time. In order to report region changes in a timely manner, the region monitoring service requires network connectivity.

In iOS 6, regions with a radius between 1 and 400 meters work better on iPhone 4S or later devices. (In iOS 5, regions with a radius between 1 and 150 meters work better on iPhone 4S and later devices.) On these devices, an app can expect to receive the appropriate region entered or region exited notification within 3 to 5 minutes on average, if not sooner.

https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instm/CLLocationManager/startMonitoringForRegion :

关于ios - 如何为超过 20 个区域启动 MonitoringForRegion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17088728/

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