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