objective-c:如何从位置服务中找到标题(方向)?

时间:2011-08-02 10:12:53

标签: iphone objective-c ios cllocationmanager

Iam正在处理位置服务并希望从位置服务获取标题,我有所有需要的属性,例如纬度,经度等,但我想找到方向(标题)

 (void)locationUpdate:(CLLocation *)location {
    locationLable.text = [location description];
    CLLocationCoordinate2D coordinate = [location coordinate];
    NSLog(@"This is location   %@",[location description]);
    NSLog(@"Lattitude          =   %@",[NSString stringWithFormat:@"%f", coordinate.latitude]);
    NSLog(@"Langitude          =   %@",[NSString stringWithFormat:@"%f", coordinate.longitude]);
    NSLog(@"Altitude           =   %@",[NSString stringWithFormat:@"%gm", location.altitude]);
    NSLog(@"horizontalAccuracy =   %@",[NSString stringWithFormat:@"%gm", location.horizontalAccuracy]);
    NSLog(@"verticalAccuracy   =   %@",[NSString stringWithFormat:@"%gm", location.verticalAccuracy]);
    NSLog(@"Speed   =   %@",[NSString stringWithFormat:@"%gm", location.speed]);

}


- (void)headingUpdate:(CLHeading *)heading {
    NSLog(@"This is heading   %@",[heading description]);

}

- (void)viewDidLoad {
    locationController = [[MyCLController alloc] init];
    locationController.delegate = self;
    [locationController.locationManager startUpdatingLocation];
    [locationController.locationManager startUpdatingHeading];
}

我发现了一些从CLHeading获取它的线索,但仍然无法从CLHeading获取它。我正在使用上面的代码

1 个答案:

答案 0 :(得分:1)

阅读http://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLHeading_Class/Reference/Reference.html :) 我想你应该使用trueHeading,我猜......

  

trueHeading

     

相对于真北的航向(以度为单位)。 (只读)   @property(readonly,nonatomic)CLLocationDirection trueHeading