【发布时间】:2012-07-24 04:16:46
【问题描述】:
好的,这是我使用 CLLoactionManager 的尝试
- (void)viewDidLoad {
[super viewDidLoad];
mapView=[[MKMapView alloc] initWithFrame:self.view.frame];
//mapView.showsUserLocation=TRUE;
mapView.delegate=self;
[self.view insertSubview:mapView atIndex:0];
CLLocationManager *locationManager=[[CLLocationManager alloc] init];
locationManager.delegate=self;
locationManager.desiredAccuracy=kCLLocationAccuracyNearestTenMeters;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
mStoreLocationButton.hidden=FALSE;
location=newLocation.coordinate;
//One location is obtained.. just zoom to that location
MKCoordinateRegion region;
region.center=location;
MKCoordinateSpan span;
span.latitudeDelta=0.01;
span.longitudeDelta=0.01;
region.span=span;
[mapView setRegion:region animated:TRUE];
}
我的问题是[locationManager startUpdatingLocation]; 似乎没有触发下一个方法。我错过了什么?我试过在第二种方法中设置断点,但它们永远不会捕获。显然它没有被使用。
【问题讨论】:
-
如果您不想要 pin,那么您可以使用 [yourMapView setShowsUserLocation:YES];
标签: ios mkmapview coordinates