MKMapView onun temsilci yönteminin mapView:viewForAnnotation: onun pim görüşlerini alır Yani sahip:
- haritanın yetki vererek görünüm denetleyicisi ayarlayın.
- Harita uygulamasıView: viewForAnnotation: kontrol cihazınızda.
delege
@interface MapViewController : UIViewController <MKMapViewDelegate>
Mark temsilci protokolü ile arayüz olarak denetleyici ayarlayın. Bu, denetleyiciyi, Arabirim Oluşturucu'da (IB) MKMapView'ın temsilcisi olarak ayarlayalım. Haritanızı içeren .xib dosyasını açın, MKMapView'a sağ tıklayın ve kontrol cihazınıza delegate
çıkışını sürükleyin.
IB yerine kod kullanmayı tercih ederseniz, denetleyicinin viewDidLoad yöntemine self.yourMapView.delegate=self;
ekleyin. Sonuç aynı olacak.
MapView Uygulamak: viewForAnnotation:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
// this part is boilerplate code used to create or reuse a pin annotation
static NSString *viewId = @"MKPinAnnotationView";
MKPinAnnotationView *annotationView = (MKPinAnnotationView*)
[self.mapView dequeueReusableAnnotationViewWithIdentifier:viewId];
if (annotationView == nil) {
annotationView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:viewId] autorelease];
}
// set your custom image
annotationView.image = [UIImage imageNamed:@"emoji-ghost.png"];
return annotationView;
}
Bunun nasıl yapılacağına dair bir örnek gösterebilir misiniz? Ben objektif için yeniyim c. Teşekkürler – 3sl