【问题标题】:how to startMonitoringForRegion for more then 20 region如何为超过 20 个区域启动MonitoringForRegion
【发布时间】:2013-06-13 13:47:11
【问题描述】:

我正在使用这个,但我不知道如何监控超过 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);

    }


}

【问题讨论】:

    标签: ios xcode core-location locationmanager region


    【解决方案1】:

    您不能监控超过 20 个区域。也许您可以根据用户位置停止监视某些区域并启动其他一些区域(取决于您的用例)。

    讨论你必须为每个你想要的区域调用一次这个方法 监视器。如果已存在具有相同标识符的区域 由应用程序监控,旧区域被替换为 新的一个。您使用此方法添加的区域由所有人共享 应用程序中的位置管理器对象并存储在 监控区域属性。

    区域事件被传递到 locationManager:didEnterRegion: 和 locationManager:didExitRegion: 委托的方法。如果有 一个错误,位置管理器调用 locationManager:monitoringDidFailForRegion:withError: 你的方法 而是委托。

    一个应用一次最多可以注册 20 个区域。为了报告 区域变化及时,区域监控服务 需要网络连接。

    在 iOS 6 中,半径在 1 到 400 米之间的区域效果更好 在 iPhone 4S 或更高版本的设备上。 (在 iOS 5 中,具有半径的区域 1 到 150 米之间的距离在 iPhone 4S 及更高版本的设备上效果更好。) 在这些设备上,应用程序可以期望接收适当的区域 在 3 到 5 分钟内进入或区域退出通知 平均,如果不是更早的话。

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

    【讨论】:

    • " . . 区域监控服务需要网络连接" 这行似乎很混乱。信标监控或地理围栏或两者都需要连接为什么我们需要网络连接(我假设它的互联网)来监控。我什至在 Apple 文档中都找不到足够的解释
    猜你喜欢
    • 2014-10-27
    • 2016-05-02
    • 2017-12-10
    • 2014-10-12
    • 1970-01-01
    • 2020-09-03
    • 1970-01-01
    • 1970-01-01
    • 2020-02-19
    相关资源
    最近更新 更多