Есть более одного Pin Pin Annotation?MapKit - PullRequest
0 голосов
/ 10 марта 2012

На данный момент у меня есть 1 пин, когда вы нажимаете на пин, он отображает информацию. Однако я хочу более 1 булавки в разных местах. Как бы я это сделал?

Это мой код.

Map.m

- (void)viewDidLoad
{


    [super viewDidLoad];

    [mapview setMapType:MKMapTypeStandard];
    [mapview setZoomEnabled:YES];
    [mapview setScrollEnabled:YES];

    MKCoordinateRegion region = { {0.0, 0.0 }, {0.0, 0.0 } };
    region.center.latitude = 52.509078;
    region.center.longitude = -1.884799;
    region.span.longitudeDelta = 0.01f;
    region.span.latitudeDelta = 0.01f;
    [mapview setRegion:region animated:YES];

    NewClass *ann = [[NewClass alloc] init];
    ann.title = @"AVFC";
    ann.subtitle = @"Aston Villa Football Club";
    ann.coordinate = region.center;
    [mapview addAnnotation:ann];

    // Do any additional setup after loading the view, typically from a nib.
}

NewClass.h

@interface NewClass : NSObject <MKAnnotation> {


    CLLocationCoordinate2D coordinate;
    NSString *title;
    NSString *subtitle;

    NSString *titleOne;
    NSString *subtitleTwo;

}

@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;

@property (nonatomic, copy) NSString *titleOne;
@property (nonatomic, copy) NSString *subtitleTwo;
@end

1 Ответ

0 голосов
/ 10 марта 2012

Создайте свои аннотации (сколько хотите), затем добавьте их к NSArray. Вы можете добавить их к своему MKMapView, используя [mapview addAnnotations:annotationArray];

MKMapView Ref

...