在我当前的项目中。
我需要用户每移动 50 米
的位置。
所以基本上在每次 50 米
更改后打开应用程序后,我需要在 Objective c
中调用 Web 服务的用户位置。我还希望在应用程序处于后台状态时运行相同的进程。
提前致谢
最佳答案
- 你必须在应用程序启动时创建 CLLocationManager 的对象并设置它的委托(delegate)
添加以下代码获取用户的当前位置
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
现在添加 CLLocationManagaer 的委托(delegate) didUpdateToLocation 并在其中添加以下代码。
CLLocationDistance 米 = [newLocation distanceFromLocation:oldLocation];
if(meters==50) { // CALL YOU WEBSERVICE }
关于ios - 在 Mapview Xcode 中更新位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33910614/