W Wich sposób mogę wywołać funkcję, która otworzy się automatycznie mój adnotacji (z tytuł, napisy itp), zamiast poruszyć adnotacji na MapView?
Automatyczny „canShowCallOut” adnotacja IPHONE
głosy
4
2 odpowiedzi
głosy 4
4
Wdrożenie MKMapViewDelegatedelegata;
wdrożenia - (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_;; na przykład tak:
- (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_ {
MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"YourPinId"];
if (pin == nil) {
pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation_ reuseIdentifier: @"YourPinId"] autorelease];
}
else {
pin.annotation = annotation_;
}
pin.pinColor = MKPinAnnotationColorRed;
[pin setCanShowCallout:YES];
pin.animatesDrop = YES;
return pin;
}
Pokaż na mapie pin po zakończeniu ładowania:
- (void) dropPin {
[mapView addAnnotation:self.annotation];
[mapView selectAnnotation:self.annotation animated:YES];
}
- (void) mapViewDidFinishLoadingMap: (MKMapView *) mapView_ {
// if done loading, show the call out
[self performSelector:@selector(dropPin) withObject:nil afterDelay:0.3];
}
Kod ten ma właściwość o nazwie adnotację, która implementuje MKAnnotation. Ponadto, animuje muche też, ale powinien on być dość self-wyjaśniając.
HTH.
głosy 3
3
Alfons odpowiedział na pytanie, ale jeśli szukasz co dokładnie automatycznie otwiera objaśnienie, to ta część:
[mapView selectAnnotation:annotation animated:YES];













