我正在尝试在didEnterRegion代理中访问最近信标的主要值和次要值。然而,当将这些值打印到控制台时,它们返回为null。
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
if ([region isKindOfClass:[CLBeaconRegion class]]) {
CLBeaconRegion *beaconRegion = (CLBeaconRegion *)region;
int major = [beaconRegion.major intValue];
int minor = [beaconRegion.minor intValue];
NSLog(@" Major %@ Minor %@", beaconRegion.major, beaconRegion.minor);
}
}
locationManager:didEnterRegion
代理方法中,执行[yourLocationManager startRangingBeaconsInRegion:yourRegion];
,对应的委托方法是locationManager:didRangeBeacons:inRegion:
。 - Larme