/ Published in: Objective C
Search the user location and sets the administrativeArea
Expand |
Embed | Plain Text
// in viewDidLoad self.locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; // new methods // achou a localização - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"Achou local"); [locationManager stopUpdatingLocation]; // this creates a MKReverseGeocoder to find a placemark using the found coordinates MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate]; geoCoder.delegate = self; [geoCoder start]; } // this delegate method is called if an error occurs in locating your current location { NSLog(@"locationManager:%@ didFailWithError:%@", manager, error); } NSLog(@"Problemas com o reverse geocoder"); } - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{ [someError show]; [someError release];*/ self.location = [placemark administrativeArea];
You need to login to post a comment.
