एक कस्टम एनोटेशन दृश्य (मानक पिन के लिए अपने प्रतिस्थापन) बनाने के लिए, तुम सिर्फ viewForAnnotation
विधि में MKAnnotationView
की image
गुण सेट कर सकते हैं:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
{
return nil;
}
else if ([annotation isKindOfClass:[YourAnnotationClassHere class]]) // use whatever annotation class you used when creating the annotation
{
static NSString * const identifier = @"MyCustomAnnotation";
MKAnnotationView* annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView)
{
annotationView.annotation = annotation;
}
else
{
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:identifier];
}
annotationView.canShowCallout = NO; // set to YES if using customized rendition of standard callout; set to NO if creating your own callout from scratch
annotationView.image = [UIImage imageNamed:@"your-image-here.png"];
return annotationView;
}
return nil;
}
तुम भी centerOffset
संपत्ति समायोजित करने के लिए चाहते हो सकता है जिस तरह से आप चाहते हैं ठीक उसी तरह लाइन को पिन करने के लिए।
कॉलआउट के अनुकूलन के संबंध में, सबसे आसान तरीका leftCalloutAccessoryView
, rightCalloutAccessoryView
और/या detailCalloutAccessoryView
निर्दिष्ट करना है। यह आपको नियंत्रण की एक आश्चर्यजनक डिग्री देता है, छवियों, लेबल, आदि के सभी प्रकार जोड़ने
आप कॉल आउट के एक कट्टरपंथी नया स्वरूप क्या करना चाहते हैं, तो आप viewForAnnotation
NO
को canShowCallout
सेट हो सकता है और उसके बाद में setSelected
का जवाब अपने अपना खुद का कॉलआउट दिखाने के लिए कस्टम एनोटेशन व्यू। स्विफ्ट में रहते हुए, कॉलआउट को कस्टमाइज़ करने के लिए कुछ विकल्पों के लिए Customize MKAnnotation Callout View? देखें।
धन्यवाद ALOT ... :) – Abhishek
@ अभिषेक आईफोन में आईफोन आकार के उपकरणों के लिए कोई मानक पॉपओवर नियंत्रण नहीं बनाया गया है। आपको किसी तृतीय पक्ष लाइब्रेरी का उपयोग करना होगा। यदि आप Google पर खोज करते हैं या खोज करते हैं। "आईफोन पॉपओवर" के लिए, आपको बहुत सारे विकल्प दिखाई देंगे। – Rob
yup इसे धन्यवाद – Abhishek