MyAnnotation
問題は、mapView に注釈を表示するために作成されたメイン クラス : があることです。
@interface lieuAnnotation : MyAnnotation
@property(readonly, nonatomic) UIImage *uneImage; // I cannot access this property.
@end
lieuAnnotation
新しいプロパティ ( ) を使用して、このクラスから継承する 2 番目のクラスを作成しましたUIImage
。
@interface MyAnnotation : NSObject<MKAnnotation> {
// Some variables
}
// Some methods
@end
マップ上で、ピンが選択されたときに、デリゲート メソッドを呼び出す開示インジケーターを設定しました。
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
[self detailPinVue:view]; // Personnal method
}
開示インジケータはlieuAnnotation
インスタンスに対してのみ表示されることに注意してください
したがってview.annotation
、インスタンスにする必要がありlieuAnnotation
ます。
次に、自分のプロパティにアクセスしたい:
- (void)detailPinVue:(MKAnnotationView *)view
{
[aView addSubview:view.annotation.uneImage];
}
Xcodeが教えてくれるので、プロパティにアクセスできませuneImage
ん:
タイプ「id」のオブジェクトにプロパティ「uneImage」が見つかりません
しかし、私の考えでは、それは可能であるべきです!
だから私もその方法でそれにアクセスしようとしました:
lieuAnnotation *anno = [[lieuAnnotation alloc] init];
anno = view.annotation;
[aView addSubview:anno.uneImage];
しかし、うまくいきません…</p>
助けとアイデアをありがとう。