/ / पिन डिजाइन बदलें - आईफोन, आईओएस, मैकनोटेशन

पिन डिजाइन बदलें - आईफोन, आईओएस, mkannotation

क्या MKAnnotation pin को अपने खुद के डिज़ाइन के png में बदलना संभव है?

यहां छवि विवरण दर्ज करें

उत्तर:

उत्तर № 1 के लिए 4

इसे ओवरराइड करें और विधि को ओवरराइड करने के लिए MKMapViewDelegate का प्रतिनिधि बनें।

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

एनोटेशन बनाएं,

MKAnnotationView *annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];// get a dequeued view for the annotation like a tableview

if (annotationView == nil)
{
annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease];
}
annotationView.annotation = annotation;
annotationView.canShowCallout = YES; // show the grey popup with location etc
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
///[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;

annoationView.image = [UIImage imageNamed:@"random.png"];

कस्टम छवि किया


जवाब के लिए 2 № 2

हां, व्यूफॉरनोटेशन डेलिगेट कॉलबैक में, आप जो भी दृश्य पसंद करते हैं, प्रदान कर सकते हैं।


उत्तर № 3 के लिए 1

कस्टम एनोटेशन छवि के लिए, छवि संपत्ति सेट करें, जैसे।

UIImage *annImage = [UIImage imageNamed:@"AnnotationIcon.png"];
annView.image = annImage;

ध्यान दें कि MKPinAnnotationView एनिमेट्रॉप प्रॉपर्टी कस्टम इमेज पर काम नहीं करेगी। हालांकि उस एनीमेशन को डुप्लिकेट करने का एक तरीका है मैं MKAnnotationView को कैसे हटाऊं?