0

私はそれが可能かどうか、またはそれが代替案ではないかどうか疑問に思いましたか?地図に表示する必要のある情報が必要で、問題が発生しています... MKPointAnnotationは優れたインターフェイスを提供しますが、一度に複数のコールアウトを開くことができませんでした。ありがとう!

4

2 に答える 2

0

私は解決策を見つけました:

最初にこれを読む必要があります:

http://developer.apple.com/library/ios/#DOCUMENTATION/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html

そして、ここに例があります:

http://shawnsbits.com/blog/2011/04/12/custom-map-pins-for-mapkit/

重要なのは、viewDidLoad でカスタマイズされた画像を使用して注釈の配列をロードし、次に mapView:viewForAnnotation で新しい MKAnnotationView を作成し、渡されたカスタマイズされた注釈に注釈をキャストすることで画像をロードすることです。

これが役立つことを願っています。ややこしく見えたらごめんなさい!

于 2012-05-06T13:24:42.533 に答える
0

注釈にボタンを追加し、ボタンにタグを設定します。これをカスタム注釈でも使用できますが、最終的なアプローチは以下と同じです。複数の注釈を開くには識別子(タグ)を設定する必要があります。

  - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {

     {

         MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.map      dequeueReusableAnnotationViewWithIdentifier: @"restMap"];
         if (pin == nil) {
            pin = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"restMap"] autorelease];
          }

          else {
              pin.annotation = annotation;
               }

          // add cutom button by following way.
          UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeCustombutton];


          // you just need to find an integer value that matches your object in some way:
          // its index in your array of MKAnnotation items, or an id of some sort, etc

          NSInteger annotationValue = [self.annotations indexOfObject:annotation];

          // set the tag property of the button to the index
          detailButton.tag = annotationValue;

          pin.rightCalloutAccessoryView = detailButton;
          return pin;
    }




     -(IBAction)showDetailofannotation:(UIView*)sender {
       // get the tag value from the sender
        NSInteger annotationtag = sender.tag;
        MyAnnotationObject *selectedObject = [self.annotations objectAtIndex:annotationtag ];

   // now you know which detail view you want to show; the code that follows

        YourDetailViewController *detailView = [[YourDetailViewController alloc] initWithNibName:@"YourDetailViewController ", NSBundle:nil];
detailView.detailObject = selectedObject;

       [[self navigationController] pushViewController:detailView animated:YES];
        [detailView release];`
     }

うまくいけば、これはあなたを助けるでしょう..

于 2012-05-06T03:15:41.013 に答える