Hi All,I have Problem with get current locations latitide and longitude.
My code is described in below:
(void)viewDidLoad { [super viewDidLoad]; locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m [locationManager startUpdatingLocation]; }
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { int degrees = newLocation.coordinate.latitude; double decimal = fabs(newLocation.coordinate.latitude - degrees); int minutes = decimal * 60; double seconds = decimal * 3600 - minutes * 60; NSString *lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"", degrees, minutes, seconds]; latLabel.text = lat; degrees = newLocation.coordinate.longitude; decimal = fabs(newLocation.coordinate.longitude - degrees); minutes = decimal * 60; seconds = decimal * 3600 - minutes * 60; NSString *longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"", degrees, minutes, seconds]; longLabel.text = longt; }
My Output is coming on ios 3G but does not working in ios 4G.
latitude:37° 19' 54.0804" longitude:-122° 1' 50.6316"
Output is coming in simulator as well as Device also in iphone 3 ios but does not works in iphone 4 ios.I have setting in my device->Setting->General->Location Service->(ON).i.e my Location Service is also ON(enabled).My Mac os version is 10.6.4 and xcode version is 3.2.3.Please,Can anybody tell me what is the problem.I'm not understanding what is the problem.I think this problem is related to GPS Setting but not understanding. Please help me.thanks in advance.......
Regards! Rupnarayan Basena