0
我想在我的控制台中只是NSLog
坐标,但它不工作。iOS 8 CLLocationManager
我在头
@implementation ViewController {
CLLocationManager *locationManager;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
NSLog(@"%f", currentLocation.coordinate.longitude);
NSLog(@"%f", currentLocation.coordinate.latitude);
}
}
链接的核心位置,但我不是在控制台中得到任何东西,没有任何人知道什么可以去错了吗?
检查:http://stackoverflow.com/questions/24717547/ios-8-map-kit-obj-c-cannot-get-users-location – Sreejith 2014-10-19 17:02:43