So now I'm at least getting callbacks with the following code...
- (void)viewDidLoad {
[super viewDidLoad];
mapView=[[MKMapView alloc] initWithFrame:self.view.frame];
//mapView.showsUserLocation=TRUE;
mapView.delegate=self;
[self.view insertSubview:mapView atIndex:0];
NSLog(@"locationServicesEnabled: %@", [CLLocationManager locationServicesEnabled] ? @"YES":@"NO");
CLLocationManager *newLocationManager = [[CLLocationManager alloc] init];
[newLocationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[newLocationManager setDistanceFilter:kCLDistanceFilterNone];
[self setLocationManager:newLocationManager];
[[self locationManager] setDelegate:self];
[[self locationManager] startUpdatingLocation];
NSLog(@"Started updating Location");
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"Did update to location");
mStoreLocationButton.hidden=FALSE;
location=newLocation.coordinate;
MKCoordinateRegion region;
region.center=location;
MKCoordinateSpan span;
span.latitudeDelta=0.01;
span.longitudeDelta=0.01;
region.span=span;
[mapView setRegion:region animated:TRUE];
}
I can set breakpoints in the second method and NSLog is reporting continual location updates, but for some reason the zoom with span isn't working. Any idea why? It's got my coordinates and everything. Sort of scratching my head on this one.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…