【问题标题】:iOS: How to find user location without using Location Services?iOS:如何在不使用定位服务的情况下找到用户位置?
【发布时间】:2014-12-10 06:42:08
【问题描述】:

是否有任何替代方法可以获取用户位置并执行 GeoFence,而不是在 iOS 中使用位置服务。我问这个是因为,当我们启用定位服务时,电池消耗太高了。这就是为什么我正在寻找替代方案。我可以尝试什么?

【问题讨论】:

  • 这叫区域监控:developer.apple.com/library/ios/documentation/userexperience/… 但当然不是很准确。在某些情况下,例如您需要越过边界并在那里停留 10 秒左右,然后系统会将其注册为区域穿越。区域监控使用更少的电池(因为它不太准确)。
  • 您使用什么技术来定位用户。 WWDC 视频和核心位置编程指南提供了有关如何减少电池影响的建议 - 特别是降低所需的精度、增加更新前的距离以及使用重要的位置更改服务

标签: ios gps cllocationmanager gprs


【解决方案1】:

如果您使用的是地图,则无需实现定位服务代码来捕获当前位置,将MKMapView [self.mapView setShowsUserLocation:YES];的showUserLocation属性设置为YES并实现其委托方法:

- (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];
}

现在您可以享受当前位置 :)

【讨论】:

    猜你喜欢
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-08
    • 1970-01-01
    • 1970-01-01
    • 2012-08-08
    • 1970-01-01
    相关资源
    最近更新 更多