标签: clcircleregion

iOS Geofence CLCircularRegion监控.locationManager:didExitRegion似乎没有按预期工作

我目前正试图让我的应用程序监控特定区域使用CoreLocation但是我发现它似乎没有按预期工作,在我看来,它不能用于每个位置的小半径设置,即10米.

我还整理了一个小测试应用程序,在地图上绘制圆形半径,以便我可以直观地看到发生了什么.

我用于监控位置的代码如下:

self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;

// Set-up a region
CLLocationDegrees latitude = 52.64915;
CLLocationDegrees longitude = -1.1506367;
CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(latitude, longitude);

CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:centerCoordinate
                                                                 radius:10 // Metres
                                                             identifier:@"testLocation"];

[self.locationManager startMonitoringForRegion:region];
Run Code Online (Sandbox Code Playgroud)

我没有在这里为DidEnter区域等提出代码,因为我知道当我离监控区域超过100米时可以工作.

这是应用程序的屏幕截图,当我距离地图上的紫色位置超过10米时,确实的出口区域事件不会触发,但是如果我将我的位置切换到伦敦则会触发它以及当我设置我的位置时回到目前蓝色位置的地方它也会发射.

示例区域

有没有人知道最小区域半径是否有限制,或者我做错了什么.

谢谢亚伦

core-location cllocationmanager ios geofencing clcircleregion

29
推荐指数
4
解决办法
2万
查看次数

iOS 7 didEnterRegion根本没有被调用

我使用以下代码来监控iOS应用中的区域.当我在iOS6上构建应用程序时,它非常有效.当我在iOS7上构建它时,不会触发didEnterRegion.

//使用iOS创建并注册区域

CLLocationCoordinate2D venueCenter = CLLocationCoordinate2DMake([favoriteVenue.venueLat      doubleValue], [favoriteVenue.venueLng doubleValue]);
CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:venueCenter radius:REGION_RADIUS identifier:favoriteVenue.venueId];

AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[appDelegate.locationManager startMonitoringForRegion:[self regionForVenue:favoriteVenue]];
Run Code Online (Sandbox Code Playgroud)

//在AppDelegate.m中

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
    NSLog(@"Entered region: %@", region.identifier);
}
Run Code Online (Sandbox Code Playgroud)

我还在plist文件中将所需的后台模式设置为"应用寄存器以进行位置更新".

有关此功能缺少什么的想法可以在iOS7上运行吗?

谢谢!

cllocationmanager clregion ios7 clcircleregion

6
推荐指数
1
解决办法
957
查看次数

你能用CLLocationManager阻止区域在启动之间保持不变吗?

有没有办法阻止CLLocationManager在启动之间保持受监控的区域?每次启动应用程序时,我都需要添加一组新的受监控区域,而旧区域则不再有用.有没有办法阻止他们在发布时坚持或清除所有旧的?

core-location ios geofencing clregion clcircleregion

5
推荐指数
1
解决办法
1107
查看次数