1

「xcode」プロジェクトを実行しようとすると、いくつかの問題が発生し、この「実行時」エラーが発生します。

Assertion failure in -[CLLocationManager startRangingBeaconsInRegion:], /SourceCache/CoreLocationFramework/CoreLocation-1613.35/Framework/CoreLocation/CLLocationManager.m:991
2014-05-11 15:47:15.483 Ziew[1516:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: region != nil'

「Estimote SDK」を使用して、近接アプリケーションのコード例を使用して同様のアプリケーションを構築しようとしています。元の例はうまく機能し、コードを追加したときに何も変更しませんでした。ここに私の方法のいくつか:

- (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 を割り当てて、startRangingBeaconsInRegion メソッドを呼び出すことができます。

self.beaconRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID
                                                                 major:your_major_id
                                                                 minor:your_minor_id
                                                            identifier:@"RegionIdentifier"];
4

2 に答える 2

2

私が言えることは、あなたがビーコンの測距を開始するように指示した時点で、あなたのビーコン リージョンはゼロになっているということです。領域の初期化されたインスタンスをプロパティに割り当てるため、プロパティ宣言が強いものではなく弱いものとしてリストされている可能性がありますか?

于 2014-05-11T22:19:21.147 に答える