因此,我创建了一个 CLLocationManager,调用它开始更新,将 mapView.showsUserLocation 设置为 YES,并为 userLocation 注释返回 nil。以下是我的 UIMapViewController 中代码的一些片段:
- (void)viewDidLoad
{
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D userCoordinate = locationManager.location.coordinate;
[map setCenterCoordinate:userCoordinate animated:YES];
[map setShowsUserLocation:YES];
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *mapIconView = (MKAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:@"mapIconView"];
// Don't mess with the user location annotation
if (annotation == mapView.userLocation)
return nil;
// etc.
}
这一切看起来都很简单。一切正常——地图按原样缩放到我的位置,并且我确认所有方法都按预期调用——但没有蓝点。无论我在哪里或说多少次,都无法为我的一生获得蓝点
mapView.setUserLocation = YES;
我在这里想念什么?