【发布时间】:2014-05-26 14:08:33
【问题描述】:
我正在开发一个简单的应用程序,它使用 iOS7.1 中的 CoreLocation 来确定预设的 iBeacon。
我的代码运行良好,直到它突然停止。我没有更改代码中的任何内容。
在“ViewDidLoad”上开始监控后,“monitoringDidFailForRegion”上发生的错误是“kCLErrorDomain error 5”:
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"0E82E0A4-03FF-4A92-9C87-1F978917BD51"];
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"com.henry.beacon"];
self.beaconRegion.notifyEntryStateOnDisplay = YES;
if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]])
{
NSLog(@"Monitoring is available.");
[self.locationManager startMonitoringForRegion:self.beaconRegion];
[self.locationManager requestStateForRegion:self.beaconRegion];
}
代理设置正确:
@interface ViewController : UIViewController <CLLocationManagerDelegate>
我检查了受监控的区域数量并
[[self.locationManager monitoredRegions] count]
向我显示当前正在监视 2 个区域。奇怪。
唯一有帮助的是重置 iOS 设备(iOS7.1 的 iPad Mini)。之后监控区域的数量又回到了1(应该是正确的)。
你们中是否有人遇到过同样的情况,我在代码中做错了什么?这是 iOS 7.1 中的错误吗?
感谢任何 cmets / 帮助。
亨利
更新:
我发现了另一个关于这个主题的帖子,它提供了一些有趣的见解:
iBeacon: didRangeBeacons stops getting called, must reset device for it to work again
好像真的是iOS7.1的一个bug。感谢你们的cmets。
【问题讨论】:
标签: ios monitoring core-location ibeacon ios7.1