J'ai donc créé un CLLocationManager, appelé pour commencer la mise à jour, défini mapES.showsUserLocation sur YES et renvoyé nil pour l'annotation userLocation. Voici quelques extraits de mon code dans mon UIMapViewController:showsUserLocation n'affiche pas de point bleu dans l'iPhone 4.0
- (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.
}
Tout cela semble assez simple. Tout fonctionne bien - la carte effectue un zoom sur mon emplacement comme il se doit, et j'ai confirmé que toutes les méthodes sont appelées comme prévu - mais pas de point bleu. Impossible d'obtenir le point bleu pour la vie de moi, peu importe où ou combien de fois je dis
mapView.setUserLocation = YES;
Qu'est-ce que je manque ici?
Merci, mais cela ne semble rien changer. Toujours pas de point. Je peux parcourir le code et regarder le {return nil; } appelé, donc je ne pense pas que le problème est là. – Aeonaut
C'est un très bon point. Le paramètre userLocation de la vue carte est initialement nul, il est donc préférable de vérifier la classe de l'annotation au lieu de la comparer à mapView.userLocation. – spstanley