जो रास्ते में मैं MapView पर एनोटेशन पर स्पर्श करने के लिए, समारोह है कि स्वचालित रूप से मेरी एनोटेशन (शीर्षक, उपशीर्षक, आदि के साथ) खोलने कह सकते हैं बजाय?
स्वत: "canShowCallOut" एनोटेशन IPHONE
वोट
4
2 जवाब
वोट 4
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।
वोट 3
3
Alfons सवाल का जवाब दे, लेकिन आप देख रहे हैं वास्तव में क्या स्वचालित रूप से कॉल आउट खोलता है के लिए, यह इस हिस्सा है:
[mapView selectAnnotation:annotation animated:YES];













