地理围栏退出区域委托方法触发了稳定位置的设备iOS(objective-c)

时间:2018-01-25 08:12:16

标签: ios objective-c iphone geofencing

我已在我的应用中实施了地理围栏。 CLRegion半径为200米。即使设备处于CLRegion区域内的稳定位置,CLRegion边界Exitregion委托方法也会触发。

这是我的代码

locationmanager = [[CLLocationManager alloc] init];
locationmanager.delegate = self;
locationmanager.distanceFilter = kCLDistanceFilterNone;
locationmanager.desiredAccuracy = kCLLocationAccuracyBest;
[locationmanager requestAlwaysAuthorization];

if (locationmanager.locationServicesEnabled) {
    [locationmanager startUpdatingLocation];
}

CLLocationCoordinate2D center = CLLocationCoordinate2DMake(13.051404,
                                                           80.179970);
CLRegion *bridge = [[CLCircularRegion alloc]initWithCenter:center
                                                    radius:200.0
                                                identifier:@"Bridge"];


[locationmanager startMonitoringForRegion:bridge];
[locationmanager startMonitoringSignificantLocationChanges];


-(void)locationManager:(CLLocationManager *)manager
   didUpdateToLocation:(CLLocation *)newLocation
          fromLocation:(CLLocation *)oldLocation {

    NSLog(@"location notific %f %f",oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
    NSLog(@"location notific2 %f %f",newLocation.coordinate.latitude, newLocation.coordinate.longitude);
   [locationManager stopUpdatingLocation];


}

任何人都可以建议我有解决方法吗?

1 个答案:

答案 0 :(得分:0)

您没有使用地理围栏委托方法。您正在使用标准位置委托方法。在文档中搜索locationManager:didEnterRegion:和didExitRegion方法