[英]How to get which annotation bubble clicked
I am creating annotation bubble buttons with the following code: 我正在使用以下代码创建注释气泡按钮:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MKPinAnnotationView *view = [mapView dequeueReusableAnnotationViewWithIdentifier:@"ParkPlaceMark"];
if(!view)
{
view=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"ParkPlaceMark"];
}
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self action:@selector(ShowDetails:)forControlEvents:UIControlEventTouchUpInside];
view.rightCalloutAccessoryView = rightButton;
[view setCanShowCallout:YES];
return [view autorelease];
}
How do i get that which annotation is clicked so that i go to details screen with the id and fetch the database record based on that id to show info. 我如何获得单击了哪个批注的信息,以便转到带有ID的详细信息屏幕,并根据该ID获取数据库记录以显示信息。
Please help. 请帮忙。
您应该实现以下委托方法:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
appDelegate.mallIDStr=[dict valueForKey:@"Mall_Id"];
self.tabBarController.selectedIndex = 2;
}
in above code i save mall id when click on any pin that show the mall location 在上面的代码中,当我单击显示购物中心位置的任何图钉时,我都会保存购物中心ID
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.