3

2つのボタンでカスタムコールアウトを表示したいのですが、両方のボタンでアクションを実行したいのですが、

ここに画像の説明を入力してください

私はそれを試しますが、マップ上でこのタイプのコールアウトを実行しません。これは実際には私が望んでいたものではありません。私はiPhoneアプリケーションを作成しているので、MKMapviewを初めて使用するため、同じことを行うのが難しくなっています。2つのボタンでカスタムコールアウトを表示するにはどうすればよいですか?

4

1 に答える 1

0

あなたは左と右の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を使用して別のボタンを追加できます。

于 2013-01-12T13:05:36.060 に答える