是否可以选择获取用户位置并执行GeoFence而不是在iOS中使用位置服务。为什么我这样问,当我们启用定位服务电池消耗太高时。这就是我寻找替代品的原因。任何人都可以帮我解决任何想法或代码片段它真的很棒。
答案 0 :(得分:0)
如果您正在使用map,则无需实现位置服务代码来捕获当前位置,将YES设置为MKMapView的
[self.mapView setShowsUserLocation:YES];
and implement it's delegate method-
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
`
[self.mapView setShowsUserLocation:YES];
[self.mapView setDelegate:self];
[self.mapView setMapType:MKMapTypeStandard];
[self.view addSubview:self.mapView];
[self.view bringSubviewToFront:self.viewLiveDrive];`
代表:
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{
NSLog(@"Location Current : %@ ",userLocation.location);
[self.mapView setCenterCoordinate:userLocation.location.coordinate animated:YES];
}
现在你可以享受当前的位置:)