我有大量引腳的地圖視圖,每個引腳都有獨特的註釋。該地圖還顯示用戶位置的脈衝藍點。到目前爲止,我只能確定一個針是否被觸摸,而不是被觸摸的特定針。檢測觸摸了哪個特定的地圖引腳
如何確定用戶觸摸的地圖中的特定引腳?我正在使用Xcode v6.1。示例代碼(對於許多引腳之一):
- (void)viewDidLoad {
[super viewDidLoad];
//** Data for Location 1 **
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = 45.5262223;
region.center.longitude = -122.63642379999999;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapView setRegion:region animated:YES];
[self.mapView setDelegate:self];
DisplayMap *ann = [[DisplayMap alloc] init];
ann.title = @"This is Location 1";
ann.subtitle = @"1234 North Main Street";
ann.coordinate = region.center;
[self.mapView addAnnotation:ann];
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
NSLog(@"This logs when any pin is touched, need to know which pin");
}
完美的作品!非常感謝您的準確答案和詳細解釋。對不起,我不能投票你的答案,但我的聲譽不夠高。但是,再次感謝! – Cheesehead1957 2014-11-01 17:54:08