开发者

problem in getting the altitude value using CLLocationManager in iphone sdk

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜