开发者

problem in getting the altitude value using CLLocationManager in iphone sdk

开发者 https://www.devze.com 2023-02-27 11:08 出处:网络
I am using the code as I specified below to get the altitude value -(void)awakeFromNib { locmanager = [[CLLocationManager alloc] init];

I am using the code as I specified below to get the altitude value

-(void)awakeFromNib {

    locmanager = [[CLLocationManager alloc] init]; 
    [locmanager setDelegate:self]; 
    [locmanager setDesiredAccuracy:kCLLocationAccuracyBest];

    [locmanager startUpdatingLocation];

}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 

    heightMesurement.text = [NSString stringWithFormat: @"%.2f m", newLocation.altitude];
}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 
{ 
    heightMesurement.text = @"0.00 m";
}

The didUpdateToLocation method is calling and I am getting the altitude value as null when I print heightMesurement.text.

Can anyone开发者_如何转开发 give me idea why this happening like this and how to rectify it.

Thanks to all, Monish.

0

精彩评论

暂无评论...
验证码 换一张
取 消