プロパティ(NameTableとID)を指定したカスタムアノテーションが多数あります。作成時にAddAnnotationの前にこのプロパティを設定しましたが、デリゲートメソッドのこれらのプロパティは表示されなくなりました。データベースから取得したテーブルの要素に関連付けられた複数の注釈があります。デリゲートメソッドでそれらを表示するにはどうすればよいですか?
- (void)viewDidLoad
{
//......
for(int i=0; i<6; i++){ //loop for create multiple annotations
AnnotationCustom *annotationIcone =[[AnnotationCustom alloc]initWithCoordinates:coord
title:self.myTable.title subTitle:self.myTable.address];
annotationIcone.nameTable = [NSString stringWithFormat:@"%@", self.myTableName];
annotationIcone.ID = i+1;
[self.mapView addAnnotation: annotationIcone;
//.....
}
しかし、デリゲートメソッドでは:
(MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id
<MKAnnotation>)annotation
{
NSLog(@"The name of table is:@"%@", annotation.nameTable);
//property 'nameTable' not found on object of type '_strong id <MKAnnotation>
NSLog (@The name of table is:@%@", annotation.ID);
//property 'ID' not found on object of type '_strong id <MKAnnotation>
//......
}
別の方法では:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
NSLog(@"The name of table is %@", self.myTableName);
// here I get the name of last table open and not the name of table selected
}