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