Ios 带有Estimote的断言失败
当我试着运行我的“xcode”项目时,我遇到了一些问题,我得到了这个“运行时”错误 我正在尝试使用“Estimote SDK”使用代码示例构建一个类似的应用程序。最初的示例非常有效,当我添加他们的代码时,我没有做任何更改。以下是我的一些方法:Ios 带有Estimote的断言失败,ios,objective-c,estimote,Ios,Objective C,Estimote,当我试着运行我的“xcode”项目时,我遇到了一些问题,我得到了这个“运行时”错误 我正在尝试使用“Estimote SDK”使用代码示例构建一个类似的应用程序。最初的示例非常有效,当我添加他们的代码时,我没有做任何更改。以下是我的一些方法: - (id)initWithBeacon:(ESTBeacon *)beacon { self = [super init]; if (self) { self.beacon = beacon; }
- (id)initWithBeacon:(ESTBeacon *)beacon
{
self = [super init];
if (self)
{
self.beacon = beacon;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithRed:(141/255.0) green:(198/255.0) blue:(63/255.0) alpha:1]];
// Do any additional setup after loading the view.
//Beacon Manager setup
self.beaconManager = [[ESTBeaconManager alloc] init];
self.beaconManager.delegate = self;
self.beaconRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:self.beacon.proximityUUID
major:[self.beacon.major unsignedIntValue]
minor:[self.beacon.minor unsignedIntValue]
identifier:@"RegionIdentifier"];
[self.beaconManager startRangingBeaconsInRegion:self.beaconRegion];
}
#pragma mark - ESTBeaconManager delegate
- (void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ESTBeaconRegion *)region
{
if (beacons.count > 0)
{
ESTBeacon *firstBeacon = [beacons firstObject];
[self textForProximity:firstBeacon.proximity];
}
NSLog(@"No beacons within region");
}
#pragma mark -
- (void)textForProximity:(CLProximity)proximity
{
switch (proximity) {
case CLProximityFar:
NSLog(@"Far");
break;
case CLProximityNear:
NSLog(@"Near");
break;
case CLProximityImmediate:
NSLog(@"Immediate");
break;
default:
NSLog(@"Unknown");
break;
}
}
- (void)viewDidDisappear:(BOOL)animated
{
[self.beaconManager stopRangingBeaconsInRegion:self.beaconRegion];
[super viewDidDisappear:animated];
}
我错过了什么
解决方案
感谢所有回应的人。使用Estimote SDK,您可以使用信标对应的主id和次id分配一个常量UUID,以获得调用的StartRangBeaconRegion方法
self.beaconRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID
major:your_major_id
minor:your_minor_id
identifier:@"RegionIdentifier"];
据我所知,当你告诉它开始对信标进行测距时,你的信标区域为零。由于您为属性指定了一个区域的初始化实例,因此您的属性声明可能被列为弱而不是强?您可能已经从演示中复制了initWithBeacon构造函数,并且在实例化视图控制器时(如从xib或故事板)不会调用此构造函数 因为self.beacon是nil,所以构造的Esregion对象被分配了nil参数,这会导致崩溃 您需要:
- 首先是你周围的信标范围
- 在应用程序中硬编码信标标识符(或从某处获取)
initWithBeacon
从未被调用,导致其值为零。我最终硬编码了信标标识符。
self.beaconRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID
major:your_major_id
minor:your_minor_id
identifier:@"RegionIdentifier"];