2013-06-13 3 views
0

им, используя это, но я не знаю, как контролировать более 20 регионов, потому что его максимальное количество региона в ИОС может контролироватьсякак startMonitoringForRegion для более 20 региона

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); 

    } 


} 

ответ

2

Вы просто не можете контролировать более чем 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:

+0

«. Служба мониторинга региона требует подключения к сети» эта линия представляется весьма запутанной. Требуется ли подключение в мониторинге маяков или в Geofencing или как Почему мы нуждаемся в подключении к сети (я предполагаю, что его Интернет) контролирует. Я даже не нашел достаточного объяснения в документах Apple –

Смежные вопросы