我正在用下面的代码创建注释气泡按钮:
-(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];
}如何获取被单击的注释,以便使用id转到详细信息屏幕,并根据该id获取数据库记录以显示信息。
请帮帮忙。
发布于 2010-10-12 15:34:28
您应该实现此委托方法:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control发布于 2010-10-12 15:45:19
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
appDelegate.mallIDStr=[dict valueForKey:@"Mall_Id"];
self.tabBarController.selectedIndex = 2;
}在上面的代码中,当点击显示商城位置的任何图钉时,我保存了商城id
https://stackoverflow.com/questions/3912438
复制相似问题