【发布时间】:2015-11-02 02:46:22
【问题描述】:
有什么方法可以使用 ios 中的 corelocation 获取唯一的设备 gps 位置。 目前我正在使用以下代码。
- (id)init{
if (!(self = [super init]))
return nil;
//Setup the manager
manager = [[CLLocationManager alloc] init];
if (!manager) {
return nil;
}
manager.distanceFilter = kCLDistanceFilterNone;
manager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
manager.desiredAccuracy = kCLLocationAccuracyBest;
manager.delegate = self;
if ([manager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)]) {
manager.pausesLocationUpdatesAutomatically = NO;
}
if ([manager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
[manager requestAlwaysAuthorization];
}
[manager startUpdatingLocation];
return self;
}
【问题讨论】:
-
什么意思?您只想要没有 Wifi 和蜂窝精度的实际 GPS 坐标?
-
是的,如果设备不支持 wifi 或蜂窝,我只想要 gps 坐标。
-
CoreLocation 将为您提供根据 GPS、Wifi 和蜂窝网络计算的位置。您不能要求它仅使用特定的定位方法来计算位置。位置计算方法对你来说完全是黑暗的,你不应该关心它。
-
我已经检查了我的 plist 有两个我已经添加在那里的字符串。当没有互联网连接可用时,我的设备会为我提供位置。但我只想要设备位置,无论是否连接互联网。
标签: ios gps core-location