0
我正在使用mkmapview將應用程序放置到mapview上。如何識別來自viewForAnnotation的XCode MKMapView引腳
我需要能夠根據有關引腳的信息對引腳着色。
那滴地圖管腳的當前代碼:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation {
if (annotation == self.mapView.userLocation) return nil;
NSLog(@"annotation = %@", annotation);
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView* customPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
customPin.pinColor = MKPinAnnotationColorRed;
customPin.animatesDrop = YES;
customPin.canShowCallout = YES;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
customPin.rightCalloutAccessoryView = rightButton;
return customPin;
}
如果我改變行:
customPin.pinColor = MKPinAnnotationColorRed;
然後我就可以改變所有的下降銷的顏色,但我怎麼能識別哪個引腳正在被丟棄,以便我只能在需要時重新對引腳着色?
我加了日誌行:
NSLog(@"annotation = %@", annotation);
但它返回,例如:
annotation = <MapAnnotation: 0x7feabd749190>
annotation = <MapAnnotation: 0x7feac04edf50>
annotation = <MapAnnotation: 0x7feabd79f860>
如何使用這個識別碼?
或者我應該在另一個位置上着色註釋引腳嗎?
您是否在添加註釋時創建了自定義註釋類? –
選中此https://www.raywenderlich.com/90971/introduction-mapkit-swift-tutorial –