緯度と経度を取得しようとしています。実際のデバイスで次のコードを実行していますが、緯度と経度が常にゼロになります。ライブラリもインポートし、デリゲートも設定します。何が間違っていて、どうすればよいか教えてもらえますか? 私のデバイスにはios 8があります。
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
if ([locationManager locationServicesEnabled])
{
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
}
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
NSString *str=[[NSString alloc] initWithFormat:@" latitude:%f longitude:%f",coordinate.latitude,coordinate.longitude];
NSLog(@"%@",str);