gpt4 book ai didi

ios - 为什么determineState : forRegion: method called twice

转载 作者:行者123 更新时间:2023-12-01 18:56:01 25 4
gpt4 key购买 nike

我正在测试 Apple 的 AirLocate 应用程序,对这种方法的行为有点困惑。

我的代码:

  • 我创建了一个 CLBeaconRegion 并将其像键一样添加到字典中
    self.rangedRegions = [[NSMutableDictionary alloc] init];

    CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc]initWithUUIDString:@"E2C56DB5-DFFB-48D2-B060-D0F5A71096E0"] identifier:@"Group 57"];
    self.rangedRegions[region] = [NSArray array];
  • 然后我开始监控和测距
    for (CLBeaconRegion *region in self.rangedRegions)
    {
    [self.locationManager startMonitoringForRegion:region];
    [self.locationManager startRangingBeaconsInRegion:region];
    }
  • 委托(delegate)方法
    - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
    {
    if(state == CLRegionStateInside)
    {
    NSLog(@"INSIDE REGION %@",region.identifier);
    }
    else if(state == CLRegionStateOutside)
    {
    NSLog(@"OUTSIDE REGION %@",region.identifier);
    }
    else
    {
    return;
    }
    }

  • 这就是我在日志中看到的:
    2014-11-24 16:10:42.482 AirLocate[741:60b] OUTSIDE REGION E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
    2014-11-24 16:10:42.977 AirLocate[741:60b] OUTSIDE REGION Group 57

    2014-11-24 16:11:31.061 AirLocate[741:60b] INSIDE REGION E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
    2014-11-24 16:11:31.656 AirLocate[741:60b] INSIDE REGION Group 57

    为什么这个方法对 CLRegionStateInside 和 CLRegionStateOutside 都调用了两次?

    为什么控制台输出 UUID 第一行,然后是区域的标识符?正如您在代码中看到的那样,它应该只是控制台中的 region.identifier (即“Group 57”)。

    最佳答案

    看起来您在之前运行的应用程序中覆盖了两个不同的区域。尝试卸载并重新安装。

    关于ios - 为什么determineState : forRegion: method called twice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27105858/

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