0

以下のように MKAnnotation を実装しました。多くのピンを配置し、それらの各ピンの情報を配列に格納します。この配列の各メンバーは、ピンのタイトルとサブタイトルの値を与えるプロパティを持つオブジェクトです。各オブジェクトはピンに対応します。しかし、ピンをクリックしたときにピンのこれらの値を表示するにはどうすればよいですか??

@interface UserAnnotation : NSObject <MKAnnotation>
{
CLLocationCoordinate2D coordinate;

NSString *title;
NSString *subtitle;
NSString *city;
NSString *province;
}

@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *subtitle;
@property (nonatomic, retain) NSString *city;
@property (nonatomic, retain) NSString *province;

-(id)initWithCoordinate:(CLLocationCoordinate2D)c;

そして.mは

@implementation UserAnnotation

@synthesize coordinate, title, subtitle, city, province;

- (NSString *)title
{
 return title;
}

- (NSString *)subtitle
{
 return subtitle;
}

- (NSString *)city
{
 return city;
}

- (NSString *)province
{
 return province;
}

-(id)initWithCoordinate:(CLLocationCoordinate2D)c
{
coordinate=c;
NSLog(@"%f,%f",c.latitude,c.longitude);
return self;
}


@end
4

1 に答える 1

0

2 行だけ追加して、すべて完了しました。

annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
于 2010-06-17T04:20:58.090 に答える