简体   繁体   English

iOS Simulator中的CLLocationManager问题

[英]Problem with CLLocationManager in iOS Simulator

I try to show a location on the map, here is the code: 我尝试在地图上显示位置,这是代码:

locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager.location initWithLatitude:latitude longitude: longitude];
NSLog(@"%f", [selectedBuilding.latitude doubleValue]);
[locationManager startUpdatingLocation];

However, no matter what coordinates I provide, the blue dot always locates in California which seems the default behaviour, is there anything additional I need to do? 但是,无论我提供什么坐标,蓝点始终位于加利福尼亚州,这似乎是默认行为,我还需要做其他事情吗? Thanks. 谢谢。

In simulator CLLocationManager is always in headquarters of Apple. 在模拟器中,CLLocationManager始终位于Apple总部。 It's from CLLocation Class reference: 它来自CLLocation Class参考:
coordinate 坐标
The geographical coordinate information. 地理坐标信息。 (read-only) (只读)

@property(readonly, nonatomic) CLLocationCoordinate2D coordinate @property(只读,非原子)CLLocationCoordinate2D坐标
Discussion 讨论区
When running in the simulator, Core Location assigns a fixed set of coordinate values to this property. 在模拟器中运行时,“核心位置”会为此属性分配一组固定的坐标值。 You must run your application on an iPhone OS–based device to get real location values. 您必须在基于iPhone OS的设备上运行应用程序才能获取真实位置值。

Availability 可用性
Available in iPhone OS 2.0 and later. 在iPhone OS 2.0和更高版本中可用。
Declared In 宣告
CLLocation.h CLLocation.h

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM