在android中有方法getLastKnownLocation()
,它获取设备上最后一次获取的更新位置。ios等同于Android中的getLastKnownLocation
重要的是,这个位置甚至不需要从您的应用程序中获取。
我需要在IOS中做同样的事情,所以我需要最后一次从设备获取的位置,即使它不是来自我的应用程序(因为我需要的位置完全不需要精确)
谢谢。
在android中有方法getLastKnownLocation()
,它获取设备上最后一次获取的更新位置。ios等同于Android中的getLastKnownLocation
重要的是,这个位置甚至不需要从您的应用程序中获取。
我需要在IOS中做同样的事情,所以我需要最后一次从设备获取的位置,即使它不是来自我的应用程序(因为我需要的位置完全不需要精确)
谢谢。
我解决做如下:
创建一类GpsManager,如:
@interface GpsManager : NSObject <CLLocationManagerDelegate>
@property (nonatomic, retain) CLLocationManager *locationManager;
@property (nonatomic, retain) CLLocation *location;
+(GpsManager*) getShared;
@end
,我开始它的appdelegate,这个类将保存的位置,你可以使用它,它不像android的getLastKnownLocation()那样实用,但希望一点。
没有全球范围,你可以要求最后一个已知的位置。如果您的应用程序需要位置信息,那么您的应用程序使用CLLocationManager及其委托方法就没有其他办法了。
注意,有一些涉及缓存,只是检查CLLocation对象的时间戳 - 的LocationManager:didUpdateToLocation:fromLocation:
马丁