我需要得到位置和标题。一旦我运行我的代码,我只会得到标题更新,位置不会更新,因为它没有出现在日志中。
如果我禁用航向更新,我会得到我的位置坐标。如果标题更新开启,我无法获得位置。有没有人遇到过同样的问题?
这是我的设置例程和方法:
locationManager = [[CLLocationManager alloc]init];
locationManager.headingFilter = 1;
locationManager.delegate = self;
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation// fromLocation:(CLLocation *)oldLocation
{NSString *currentLatitude = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
NSLog(@"currentLatitude = %@", currentLatitude);
NSString *currentLongitude = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.longitude];
NSLog(@"currentLongitude = %@", currentLongitude);
NSString *currentHorizontalAccuracy = [[NSString alloc] initWithFormat:@"%g", newLocation.horizontalAccuracy];
NSLog(@"currentHorizontalAccuracy = %@", currentHorizontalAccuracy);
NSString *currentAltitude = [[NSString alloc] initWithFormat:@"%g", newLocation.altitude];
NSLog(@"currentAltitude = %@", currentAltitude);
NSString *currentVerticalAccuracy = [[NSString alloc] initWithFormat:@"%g", newLocation.verticalAccuracy];
NSLog(@"currentVerticalAccuracy = %@", currentVerticalAccuracy);
}- (BOOL)locationManagerShouldDisplayHeadingCalibration: (CLLocationManager *)manager {
return NO;}
-(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading{
CLLocationDirection trueHeading = newHeading.trueHeading;}