Monotouch MapKit - एनोटेशन - बुलबुला के लिए एक बटन जोड़ने

वोट
7

किसी को भी पता है कि वैसे भी अगर एक एनोटेशन पर एक बटन पाने के लिए?

मुझे पसंद स्थान चयन होने के लिए चाहते हैं - तो आप कह सकते हैं .. स्थान का चयन करें और बटन पर क्लिक करके उस स्थान पर सभी घटनाओं मिलता है।

क्या यह संभव है?

डब्ल्यू: //

02/03/2010 को 18:19
का स्रोत उपयोगकर्ता
अन्य भाषाओं में...                            


2 जवाब

वोट
13

यहाँ कोड मैं अपने एनोटेशन के लिए इस्तेमाल किया, यह बुलबुला के दाईं ओर एक बटन शामिल है। आप ढेर पर कोई नया दृश्य पुश करने के लिए आप जो कुछ भी चाहते प्रदर्शित करने के लिए एक IBAction सेट कर सकते हैं

- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKPinAnnotationView *pinAnnotation = nil;
    if(annotation != mapView.userLocation) 
    {
        static NSString *defaultPinID = @"myPin";
        pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if ( pinAnnotation == nil )
            pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];

        pinAnnotation.canShowCallout = YES;

        //instatiate a detail-disclosure button and set it to appear on right side of annotation
        UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinAnnotation.rightCalloutAccessoryView = infoButton;

    }

    return pinAnnotation;
}
02/03/2010 को 20:39
का स्रोत उपयोगकर्ता

वोट
5

मैं सिर्फ उद्देश्य सी में इस के साथ किसी और की मदद की है, लेकिन मुझे यकीन है कि अवधारणा मोनो के साथ एक ही है हूँ। आप एक कस्टम MKAnnotationView वस्तु बनाने के लिए और ओवरराइड जरूरत GetViewForAnnotation (Obj सी में viewForAnnotation) अपने MKMapViewDelegate वर्ग की विधि ... अन्य प्रश्न की जाँच

जब आप बनाने के अपने कस्टम MKAnnotationView यह आपत्ति मूल रूप से एक UIView नक्शा एनोटेशन के लिए बनाया है ... तुम सिर्फ देखने के लिए अपने बटन और अन्य जानकारी जोड़ सकते हैं और यह दिखाई देगा जब उपयोगकर्ता एनोटेशन पूरी करता है।

प्रतिनिधि विधि के लिए कुछ किसी न किसी कोड यहाँ:

public override MKAnnotationView GetViewForAnnotation(
                                         MKMapView mapView,NSObject annotation) {
      var annotationId = "location";
      var annotationView = mapView.DequeueReusableAnnotation(annotationId);
      if (annotationView == null) {
         // create new annotation
         annotationView = new CustomAnnotationView(annotation, annotationId);
      }
      else {
         annotationView.annotation = annotation;
      }
      annotation.CanShowCallout = true;
      // setup other info for view
      // ..........

      return annotationView;
   }
}
02/03/2010 को 18:30
का स्रोत उपयोगकर्ता

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more