2012-03-09 147 views
0

此刻我有1個針腳,當您點擊該針腳時,它會顯示信息。不過,我想要在不同位置使用1個以上的引腳。我將如何做到這一點?有多個引腳註釋? MapKit

這是我的代碼。

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 
+0

嘗試在這裏考慮看看它們添加到您的MKMapView,它是在開始使用MapKit,包括註釋一個很好的教程:HTTP://www.raywenderlich.com/2847/introduction- to-mapkit-on-ios-tutorial – 2012-03-09 23:37:57

回答

0

創建您的註釋(但很多你想要的)然後將它們添加到NSArray。您可以使用[mapview addAnnotations:annotationArray];

MKMapView Ref

+0

我該如何在代碼中做到這一點?謝謝 – 2012-03-09 23:31:29

+0

你對哪個部分感到困惑? – bschultz 2012-03-09 23:34:46