locationManager:didRangeBeacons:inRegion beacon数组包含同一个beacon的多个实例

时间:2015-09-21 17:13:33

标签: ios objective-c clbeacon

所以我有我的委托方法locationManager:didRangeBeacons:inRegion,它给了我NSArray个信标。通常它在阵列中只有1个信标,也就是我目前正在搜索的信标。然而,有时会发生阵列中有多个信标的情况,所有信标都具有相同的信息。它提供相同的主要,次要和UUID,但完全不同的距离读数。

肯定没有6个不同的信标与次要221,但有时它会在NSArray 6次出现。它给出的阵列中的一些距离是完全不准确的,而其他的则不是很糟糕,所以我不确定为什么完全不准确的结果就在那里。 / p>

locationManager:didRangeBeacons:inRegion内的代码如下:

-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {
    if(beacons.count>0) {
        for(int i = 0; i < beacons.count; i++) {
            NSLog(@"Beacon #%d: %@", i, [beacons objectAtIndex:i]);
        }
        CLBeacon *beacon = [[CLBeacon alloc] init];
        beacon = [beacons lastObject];

        NSLog(@"%f", beacon.accuracy);
        if(beacon.accuracy != -1.0){
            unknownCounter = 0;
            activityView.hidden = YES;
            if(searching){
                controlView.hidden = NO;
            }
            [self determineHotColdBarColor:beacon.accuracy];
        }
    }else{
        NSLog(@"Couldn't find any beacons");
    }
}

这是我在6次找到相同信标信息时得到的日志:

2015-09-21 12:49:31.327 My Beacon App[441:88487] Beacon #0: CLBeacon (uuid:<__NSConcreteUUID 0x1d91a380> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:0 +/- -1.00m, rssi:0)
2015-09-21 12:49:31.328 My Beacon App[441:88487] Beacon #1: CLBeacon (uuid:<__NSConcreteUUID 0x1d91a3c0> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:0 +/- -1.00m, rssi:0)
2015-09-21 12:49:31.328 My Beacon App[441:88487] Beacon #2: CLBeacon (uuid:<__NSConcreteUUID 0x1d91a020> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:0 +/- -1.00m, rssi:0)
2015-09-21 12:49:31.328 My Beacon App[441:88487] Beacon #3: CLBeacon (uuid:<__NSConcreteUUID 0x1d91a060> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:0 +/- -1.00m, rssi:0)
2015-09-21 12:49:31.329 My Beacon App[441:88487] Beacon #4: CLBeacon (uuid:<__NSConcreteUUID 0x1d91a0a0> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:2 +/- 0.35m, rssi:-52)
2015-09-21 12:49:31.331 My Beacon App[441:88487] Beacon #5: CLBeacon (uuid:<__NSConcreteUUID 0x1d919fe0> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:2 +/- 0.41m, rssi:-52)

如果有人知道为什么会发生这样的事情,我会非常感激。谢谢!

0 个答案:

没有答案