我有一个地图视图,并且有 10 个商店位置的数据来自网络服务。我只想推送到我的详细视图以显示点击商店的地址、电话和其他信息。
detailview
当用户在 mapkit 上点击或触摸内部注释时,我需要将数据传递给我。我的里面有10个注解,mapview
首先我想知道,我怎么理解或者如何获取点击了哪个注解的annotationID?
这是我返回别针的方法
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]]) return nil;
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView* pinView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
pinView.animatesDrop=YES;
pinView.canShowCallout=YES;
pinView.pinColor=MKPinAnnotationColorPurple;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = rightButton;
return pinView;
}
/* and my action method for clicked or tapped annotation: */
- (IBAction)showDetails:(id)sender{
NSLog(@"Annotation Click");
[[mtMap selectedAnnotations]objectAtIndex:0];
magazaDetayViewController *detail = [[magazaDetayViewController
alloc]initWithNibName:@"magazaDetayViewController" bundle:nil];
detail.sehir=@"";
detail.magazaAdi=@"";
detail.adres=@"";
detail.telefon=@"";
detail.fax=@"";
[self.navigationController pushViewController:detail animated:YES];
}
如果我只能获得单击的注释索引,我可以用我的数组填充详细属性。如果这是不可能的,还有其他方法吗?