我想显示一个带有两个按钮的自定义标注,我还想对两个按钮进行操作,
我尝试过,但没有在地图上做这种标注,这并不是我真正想要的。当我正在制作一个 iPhone 应用程序时,由于我是 MKMapview 的新手,所以我很难做到这一点。如何使用两个按钮显示自定义标注?
你可以去左右 calloutaccessoryview 看这里
//ANNOTATION VIEW SETTING DELEGATE
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
MKPinAnnotationView *myPin = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"reuseString"];
myPin.draggable = NO;
myPin.canShowCallout = YES;
myPin.pinColor = MKPinAnnotationColorRed;
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
rightButton.frame = CGRectMake(0, 0, 50, 30);
[rightButton setTitle:@"Info!" forState:UIControlStateNormal];
[rightButton setBackgroundImage:[UIImage imageNamed:@"image.png"] forState:UIControlStateNormal];
rightButton.showsTouchWhenHighlighted = YES;
[rightButton addTarget:self action:@selector(rightAcccoryViewButtonCLicked) forControlEvents:UIControlEventTouchUpInside]; //rightAcccoryViewButtonCLicked is a function
myPin.rightCalloutAccessoryView = rightButton;
return myPin;
}
同样,您可以使用leftCalloutAccessoryView并添加另一个按钮。