我已经实现了 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