स्वत: "canShowCallOut" एनोटेशन IPHONE

वोट
4

जो रास्ते में मैं MapView पर एनोटेशन पर स्पर्श करने के लिए, समारोह है कि स्वचालित रूप से मेरी एनोटेशन (शीर्षक, उपशीर्षक, आदि के साथ) खोलने कह सकते हैं बजाय?

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


2 जवाब

वोट
4

लागू MKMapViewDelegateप्रतिनिधि;

लागू - (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_;; इस तरह उदाहरण के लिए:

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

    MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"YourPinId"];
    if (pin == nil) {
        pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation_ reuseIdentifier: @"YourPinId"] autorelease];
    }
    else {
        pin.annotation = annotation_;
    }
    pin.pinColor = MKPinAnnotationColorRed;
    [pin setCanShowCallout:YES];
    pin.animatesDrop = YES;
    return pin;
}

पिन दिखाएँ के बाद नक्शा लोड हो जाए:

- (void) dropPin {
    [mapView addAnnotation:self.annotation];
    [mapView selectAnnotation:self.annotation animated:YES];        
}

- (void) mapViewDidFinishLoadingMap: (MKMapView *) mapView_ {
    // if done loading, show the call out
    [self performSelector:@selector(dropPin) withObject:nil afterDelay:0.3];
}

इस कोड को एक संपत्ति बुलाया एनोटेशन जो लागू करता है MKAnnotation। इसके अलावा, यह पिन ड्रॉप भी एनिमेट है, लेकिन यह काफी आत्म समझा जाना चाहिए।

HTH।

21/03/2010 को 21:47
का स्रोत उपयोगकर्ता

वोट
3

Alfons सवाल का जवाब दे, लेकिन आप देख रहे हैं वास्तव में क्या स्वचालित रूप से कॉल आउट खोलता है के लिए, यह इस हिस्सा है:

[mapView selectAnnotation:annotation animated:YES]; 
10/01/2012 को 05:09
का स्रोत उपयोगकर्ता

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