简体   繁体   中英

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. It's from CLLocation Class reference:
coordinate
The geographical coordinate information. (read-only)

@property(readonly, nonatomic) CLLocationCoordinate2D coordinate
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.

Availability
Available in iPhone OS 2.0 and later.
Declared In
CLLocation.h

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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