didRangeBeacons在Objective C中给出了空数组

时间:2016-03-22 06:40:26

标签: objective-c cllocationmanager ibeacon

在我的项目中我检测到信标设备。在委托方法中,它给出了空数组值

这给出了空数组值:

-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region{
NSLog(@"beacons list %@ ",beacons);
}

更新

- (void)viewDidLoad
{
    [super viewDidLoad];
 NSUUID *uuid=[[NSUUID alloc]initWithUUIDString:UUID];
    clBeconRegion=[[CLBeaconRegion alloc]initWithProximityUUID:uuid identifier:@"BluetoothExample"];
    [locManager startMonitoringForRegion:clBeconRegion];
    clBeconRegion.notifyEntryStateOnDisplay=YES;
}

1 个答案:

答案 0 :(得分:0)

为了让didRangeBeacons返回非空数组,您需要调用以下方法:

[self.locationManager startRangingBeaconsInRegion:beaconRegion];

此外,我会确保您附近的信标具有相同的UUID,并且您已在info.plist中输入了NSLocationAlwaysUsageDescription。还要确保已创建locationManager并设置其委托。