didUpdateToLocation不会立即被调用 [英] didUpdateToLocation doesn't gets called immediately
问题描述
我正在使用
startMonitoringSignificantLocationChanges
startMonitoringSignificantLocationChanges
获取(lat,lon)值.我的问题是
for getting the (lat,lon) values.My problem is
- (void)locationManager:(CLLocationManager *)managerdidUpdateToLocation:(CLLocation *)newLocationfromLocation:(CLLocation *)oldLocation
在遇到 [locationMangerObject startMonitoringSignificantLocationChanges];
之后,不会立即调用
方法.在 didUpdateToLocation
方法中,我仅维护两个全局双精度变量,用于保存纬度和经度可以从 didUpdateToLocation
方法获得的坐标中进行设置.这些值被传递到Web服务,因为didUpdateToLocation仅被称为某个延迟,在此延迟之间,(lat,lon)的参数将其值为零,并且传递给服务会导致意外响应.
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.
制作方法
- (void)locationManager:(CLLocationManager *)managerdidUpdateToLocation:(CLLocation *)newLocationfromLocation:(CLLocation *)oldLocation
在[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不会立即被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!