2つのボタンでカスタムコールアウトを表示したいのですが、両方のボタンでアクションを実行したいのですが、
私はそれを試しますが、マップ上でこのタイプのコールアウトを実行しません。これは実際には私が望んでいたものではありません。私はiPhoneアプリケーションを作成しているので、MKMapviewを初めて使用するため、同じことを行うのが難しくなっています。2つのボタンでカスタムコールアウトを表示するにはどうすればよいですか?
あなたは左と右のcalloutaccessoryviewに行くことができますHEREを見てください
//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を使用して別のボタンを追加できます。