ios - longitude and latitude values are both 0.000000 , why? -


i use core location longitude , latitude value of current position , have displayed label, case it's 0.000000 both longitude , latitude, because work on simulator ??

    //longitude , latitude     // locationmanager update location     locationmanager = [[cllocationmanager alloc] init];     locationmanager.delegate = self;      locationmanager.desiredaccuracy = kcllocationaccuracybest;      locationmanager.distancefilter = kcldistancefilternone;      [locationmanager startupdatinglocation];      cllocation *location = [locationmanager location];      // configure new event information location     cllocationcoordinate2d coordinate = [location coordinate];      nsstring *latitude = [nsstring stringwithformat:@"%f", coordinate.latitude];      nsstring *longitude = [nsstring stringwithformat:@"%f", coordinate.longitude]; 

just initialization location manager doesn't fetch values.

you have write this

[self.locationmanager startupdatinglocation]; 

then have override callback method

- (void) locationmanager:(cllocationmanager *)manager       didupdatetolocation:(cllocation *) newlocation     fromlocation: (cllocation *) oldlocation {       [self.locationmanager stopupdatinglocation];      nsstring *latitude = [nsstring stringwithformat:@"%f", newlocation.latitude];           nsstring *longitude = [nsstring stringwithformat:@"%f", newlocation.longitude];       [self.locationmanager release]; } 

hope helps!

  • shuanak

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -