gpt4 book ai didi

ios - monitoringDidFailForRegion 为 iBeacon 区域时,kCLErrorDomain 错误 5

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:39:42 26 4
gpt4 key购买 nike

我正在开发一个简单的应用程序,它使用 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 中的错误吗?

感谢任何评论/帮助。

亨利

更新:

我发现了另一个关于这个主题的话题,它提供了一些有趣的见解:

iBeacon: didRangeBeacons stops getting called, must reset device for it to work again

看来确实是iOS7.1的bug。感谢您对此发表评论。

最佳答案

检查您的蓝牙状态是打开还是关闭或蓝牙类型。可能是旧版本的蓝牙检查它。确保您的蓝牙已在设备中打开。这为我解决了这个错误。谢谢

关于ios - monitoringDidFailForRegion 为 iBeacon 区域时,kCLErrorDomain 错误 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23029197/

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