本文介绍了didUpdateToLocation不会立即被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

获取(lat,lon)值。我的问题是

for getting the (lat,lon) values.My problem is


在 [locationMangerObject startMonitoringSignificantLocationChanges]; 之后,不会立即调用

方法。在 didUpdateToLocation 仅方法我维护两个用于保存纬度和经度的全局双变量,这将通过从 didUpdateToLocation 方法获得的坐标进行设置。这些值被传递到Web服务,因为didUpdateToLocation为仅调用一个特定的延迟,在该延迟之间,(lat,lon)的参数将零作为其值,并传递给resul的服务

method doesn't gets called immediately after [locationMangerObject startMonitoringSignificantLocationChanges]; is encountered.Inside didUpdateToLocation method only i maintain two global double variables for holding latitude and longitude which will be set from the coordinates obtained from didUpdateToLocation method.These values are passed to the webservice,since didUpdateToLocation is called only a certain delay,between which the parameters for (lat,lon) takes zero as their value and passed to the service which results in an unexpected response.

如何制作

方法将在`[locationMangerObject startMonitoringSignificantLocationChanges]之后立即被调用;

method to get called immediately after `[locationMangerObject startMonitoringSignificantLocationChanges]; is encountered.

请有人建议我解决该问题的解决方案。

Please anybody suggest me a solution for resolving this issue.

在此先感谢您。

推荐答案

也许您应该考虑使用 startUpdatingLocation 方法而不是 startMonitoringSignificantLocationChanges 。从iOS文档开始:

Maybe you should consider using startUpdatingLocation method instead of startMonitoringSignificantLocationChanges. From iOS docs:

此方法立即返回。调用此方法会使位置管理器获取初始值。位置修复(可能需要几秒钟),并通过调用其locationManager:didUpdateToLocation:fromLocation:方法来通知您的代表。

This method returns immediately. Calling this method causes the location manager to obtain an initial location fix (which may take several seconds) and notify your delegate by calling its locationManager:didUpdateToLocation:fromLocation: method.

这篇关于didUpdateToLocation不会立即被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 10:09