タイトルとサブタイトルを持つ MKAnnotation 名 PushPin を作成しました。後でタイトルを動的に変更できるようにしたい。私は近いので、まったく新しい AnnotationView を作成する必要はありませんが、必要がある場合は、それも問題ないと思います。私の問題は、タイトルのテキストを変更すると、ウィンドウのサイズが変更されず、タイトルの元の大きさによっては一部のテキストが切り取られる可能性があることです。
1) 吹き出しウィンドウのサイズを再度変更するためにトリガーできるイベントはありますか?
2) また、タイトルをリセットする前に、注釈に実際にタイトルがあることを確認しますが、確認した後にキャストするのに問題がありました。誰か助けてもらえますか? 私はまだobjective-cに不慣れで、これはしばらくの間私を台無しにしました。
#import <Foundation/Foundation.h>
#import <MapKit/MKAnnotation.h>
@interface PushPin : NSObject <MKAnnotation> {
CLLocationCoordinate2D _coordinate;
NSString *_title;
NSString *_subtitle;
NSString *_ID;
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *subtitle;
@property (nonatomic, retain) NSString *ID;
- (id) initWithCoordinateAndInformation:(CLLocationCoordinate2D)coordinate title:(NSString *)title subtitle:(NSString *)subtitle;
@end
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
NSLog(@"Annotation was TAPPED!");
if ([view.annotation isKindOfClass:[PushPin class]]) {
view.annotation.title = @"test";
// warning here, that this might not be implemented...
// but it is for this class type, how do I cast it to the correct type?
}
}