次のコードを使用して、カスタム AnnotationView を作成しています。
Myはのセッター/ゲッターを持つCustomPointAnnotation
のサブクラスですMKPointAnnotation
Player
-(void) showMarkers
{
[self.mapView removeAnnotations:[self.mapView annotations]];
for (int i = 0 ; i < [self.playersArray count]; i ++)
{
Players *player = [self.playersArray objectAtIndex:i];
CustomPointAnnotation *annotationPoint = [[CustomPointAnnotation alloc] init];
[annotationPoint setPlayer:player];
if ([player.name isEqualToString:self.name.text])
{
NSLog(@"%@ , %@" , player.name,self.name.text);
annotationPoint.coordinate = CLLocationCoordinate2DMake([player.latitude doubleValue]+.1, [player.longitude doubleValue]+.1);
[self.mapView addAnnotation:annotationPoint];
}
else
{
NSLog(@"%@ , %@" , player.name,self.name.text);
annotationPoint.coordinate = CLLocationCoordinate2DMake([player.latitude doubleValue], [player.longitude doubleValue]);
[self.mapView addAnnotation:annotationPoint];
}
}
[self.mapView setUserInteractionEnabled:YES];
}
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
// self.mapView.centerCoordinate = userLocation.location.coordinate;
myLocation = userLocation;
}
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if ([[annotation title] isEqualToString:@"Current Location"] )
{
return nil;
}
CustomAnnotationView *annView = [[CustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"players"];
CustomPointAnnotation *ptAnnotation = (CustomPointAnnotation *) annotation;
[annView setPlayer:ptAnnotation.player];
annView.image = [UIImage imageNamed:@"marker.png"];
annView.enabled = YES;
[annView setUserInteractionEnabled:YES];
return annView;
}
問題は、[annView setPlayer:ptAnnotation.player]; Unrecognized selector sent to instance
CustomPointAnnotation を追加するときに発生するため、元に戻す必要があります。この問題を解決するにはどうすればよいですか