iOS:如何在不使用位置服务的情况下查找用户位置?

时间:2014-10-15 08:52:02

标签: ios gps cllocationmanager gprs

是否可以选择获取用户位置并执行GeoFence而不是在iOS中使用位置服务。为什么我这样问,当我们启用定位服务电池消耗太高时。这就是我寻找替代品的原因。任何人都可以帮我解决任何想法或代码片段它真的很棒。

1 个答案:

答案 0 :(得分:0)

如果您正在使用map,则无需实现位置服务代码来捕获当前位置,将YES设置为MKMapView的 [self.mapView setShowsUserLocation:YES]; and implement it's delegate method-

的showUserLocation属性
- (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]; } 现在你可以享受当前的位置:)