【发布时间】:2017-09-05 14:22:50
【问题描述】:
iOS 地理围栏未在目标 c 中调用 didEnterRegion、didExitRegion 和 didStartMonitoringForRegion。
我想实现一个单视图应用程序,我在可可豆荚中使用 Google 地图 SDK。
我已经像这样在 info.plist 中包含了适当的键
<key>NSLocationAlwaysUsageDescription</key>
<string>Location is required for geofence</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is required for geofence</string>
这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
double Lat=22.569643;
double Lon=88.432058;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:Lat longitude:Lon zoom:14];
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
self.view=_mapView;
_mapView.myLocationEnabled = YES;
circ = [GMSCircle circleWithPosition:CLLocationCoordinate2DMake(Lat, Lon) radius:52];
circ.fillColor = [UIColor colorWithRed:0.25 green:0 blue:0 alpha:0.05];
circ.strokeColor = [UIColor redColor];
circ.strokeWidth = 1;
circ.map = _mapView;
CLCircularRegion *cir=[[CLCircularRegion alloc]initWithCenter:CLLocationCoordinate2DMake(Lat, Lon) radius:52 identifier:@"hi"];
locationManager = [CLLocationManager new];
[locationManager requestAlwaysAuthorization];
locationManager.delegate = self;
locationManager.distanceFilter = 10.0;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startMonitoringForRegion:cir];
cir.notifyOnEntry = YES;
cir.notifyOnExit = YES;
[locationManager startUpdatingLocation];
}
【问题讨论】:
-
你在模拟器上运行你的代码吗?
-
不..它在 Iphone 上运行
标签: ios objective-c iphone google-maps geofencing