Ios 为什么间歇调用didEnterRegion委托?

Ios 为什么间歇调用didEnterRegion委托?,ios,cllocationmanager,ibeacon,Ios,Cllocationmanager,Ibeacon,这是对问题的后续行动 现在,didEnterRegion调用是“有时”进行的,但并非总是如此,如果我删除应用程序,安装应用程序并关闭信标,然后启动信标,它大部分时间都在工作,我的调试会显示所有正确的信息,但它并不可靠 我知道100%的信标是正常的和广播,因为我有一个信标扫描仪旁边的设置,我看到它直接去和关闭我的命令 这是我的全部代码,没有遗漏任何内容 #import "ViewController.h" @interface ViewController () @end @implemen

这是对问题的后续行动

现在,didEnterRegion调用是“有时”进行的,但并非总是如此,如果我删除应用程序,安装应用程序并关闭信标,然后启动信标,它大部分时间都在工作,我的调试会显示所有正确的信息,但它并不可靠

我知道100%的信标是正常的和广播,因为我有一个信标扫描仪旁边的设置,我看到它直接去和关闭我的命令

这是我的全部代码,没有遗漏任何内容

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    // Initialize location manager and set ourselves as the delegate
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
}

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
    NSLog(@"authstate changed was hit wit status %d", status);

    if (status == kCLAuthorizationStatusAuthorizedAlways) {
        // Create a NSUUID with the same UUID as the broadcasting beacon
        NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"39876A4B-43B2-4BE8-9A9C-41BAE913D56A"];

        // Setup a new region with that UUID and same identifier as the broadcasting beacon
        _myBeaconRegion= [[CLBeaconRegion alloc] initWithProximityUUID:uuid
                                                            identifier:@"me.netwizards.office"];

        [_locationManager startMonitoringForRegion:_myBeaconRegion];
        NSLog(@"location Manager started to monitor regions: %@", self.locationManager.monitoredRegions);
    } else {
        [self.locationManager requestAlwaysAuthorization];
        NSLog(@"requesting again");
    }
}


- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
    NSLog(@"Error : %@",error);
}

- (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
{
    NSLog(@"Region monitoring failed with error: %@", [error localizedDescription]);
}

- (void)locationManager:(CLLocationManager*)manager didEnterRegion:(CLRegion*)region
{
    NSLog(@"Did Enter Region");
    [self.locationManager startRangingBeaconsInRegion:self.myBeaconRegion];
}

-(void)locationManager:(CLLocationManager*)manager didExitRegion:(CLRegion*)region
{
    [self.locationManager stopRangingBeaconsInRegion:self.myBeaconRegion];
    self.viewControllerStoreLbl.text = @"No Store Detected";
    self.viewControllerOpeningTimesLbl.text = @"No Store Detected";
    NSLog(@"Did Exit Region");
}

-(void)locationManager:(CLLocationManager*)manager
       didRangeBeacons:(NSArray*)beacons
              inRegion:(CLBeaconRegion*)region
{
    // Beacon found!
    self.viewControllerStoreLbl.text = @"Matts Test Store";
    self.viewControllerOpeningTimesLbl.text = @"Open 9 AM to 9 PM";

    CLBeacon *foundBeacon = [beacons firstObject];

    // You can retrieve the beacon data from its properties
    NSString *uuid = foundBeacon.proximityUUID.UUIDString;
    NSString *major = [NSString stringWithFormat:@"%@", foundBeacon.major];
    NSString *minor = [NSString stringWithFormat:@"%@", foundBeacon.minor];

    NSLog(@"Beacon Data: UUID: %@, major: %@, minor: %@", uuid, major, minor);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
下面的调试向我展示了区域监视的启动情况,并且location manager Auth委托被称为ok并按预期工作

2017-05-05 17:05:45.102718 NW SelfCheckout[225:4033] authstate changed was hit wit status 0
2017-05-05 17:05:45.104175 NW SelfCheckout[225:4033] requesting again
2017-05-05 17:05:47.314500 NW SelfCheckout[225:4033] authstate changed was hit wit status 3
2017-05-05 17:05:47.327998 NW SelfCheckout[225:4033] location Manager started to monitor regions: {(
    CLBeaconRegion (identifier:'me.netwizards.office', uuid:39876A4B-43B2-4BE8-9A9C-41BAE913D56A, major:(null), minor:(null))
)}
但在那个之后什么也并没有发生,我可以等几个小时,打开和关闭信标,从射程中移除信标,等等,一切都不起作用,重新启动设备仍然并没有帮助


可能有什么问题?

请看:好的,我添加了对区域DetermingEstate的调用,但是我是否需要在代理中执行任何操作?或者cLl本身足以在功能上触发?是的,如果你想在这里执行任何与区域相关的操作。这似乎可行,但我需要做更多的测试,代理按预期工作,因此我补充说,如果它在内部,我开始做我的事情,现在还可以,保持tunesok@Matt Douhan