2011-08-23 15 views
8

यहां एक नमूना कस्टम कॉलआउट है जिसे मैं एक समान शैली प्राप्त करना चाहता हूं। मैं एमकेएनोटेशन से विरासत में रहने की सोच रहा था लेकिन मुझे खोना है कि इसे कैसे शुरू किया जाए और मुझे नहीं पता कि कॉलआउट के डिज़ाइन को ओवरराइड किया जा सकता है या नहीं।आईओएस मैपकिट कस्टम कॉलआउट

http://1.bp.blogspot.com/_xfo3fwc97Fg/TJ9RZrHVOaI/AAAAAAAAAU4/buhP3q3y0G4/s1600/fmip_locate_20100622.png

कोई भी विचार कैसे अंदर ui नियंत्रण के साथ इस कस्टम कॉलआउट लागू करने के लिए?

संपादित करें: यहाँ समान StackOverflow जवाब निम्नलिखित से मेरे कोड है:

- (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    if ([annotation isKindOfClass:[MKUserLocation class]]) 
     return nil; 
    static NSString* AnnotationIdentifier = @"AnnotationIdentifier"; 
    MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier]; 
    if(annotationView) 
     return annotationView; 
    else 
    { 
     UIImage *img = [UIImage imageNamed:@"default_thumb.png"]; 

     MKAnnotationView *annotationView = 
      [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier]; 
     annotationView.canShowCallout = YES; 
     annotationView.image = img; 
     annotationView.draggable = YES; 

     /* 
     // change left accessory view button with image 
     UIImageView *leftAccView = [[UIImageView alloc] initWithImage:img]; 
     annotationView.leftCalloutAccessoryView = leftAccView; 

     //include a right button to show more info   
     UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
     [rightButton addTarget:self action:@selector(calloutSubMenu:) forControlEvents:UIControlEventTouchUpInside]; 
     [rightButton setTitle:annotation.title forState:UIControlStateNormal]; 
     annotationView.rightCalloutAccessoryView = rightButton;   
     */ 

     return annotationView; 
    } 
    return nil; 
} 

// Customize accessory view 
- (void)mapView:(MKMapView *)mapview annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 
{ 
    [mapview deselectAnnotation:view.annotation animated:YES]; 

    PopOverCallout *popOverCallout = [[PopOverCallout alloc]init]; 

    UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:popOverCallout]; 

    self.annotationPopoverController = popOver; 

    popOver.popoverContentSize = CGSizeMake(500, 500); 

    [popOver presentPopoverFromRect:view.bounds inView:view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];  
} 

जब भी पिन कॉलआउट सही दिखाने के लिए छुआ है

(void)mapView:(MKMapView *)mapview annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 

बुलाया जाना चाहिए? लेकिन क्या होता है कि एक खाली नियमित कॉलआउट दिखाया जाता है। मैं गलत क्या कर सकता हूँ?

बीटीडब्ल्यू: UIViewController subclass के पास केवल XIB पर एक लेबल है और यह बहुत खाली है।

+3

देखें [यह वही प्रश्न] (http://stackoverflow.com/questions/5582564/how-do-i-display-a-uipopoverview-as-a-annotation-to-the-map-view-ipad/ 5583505 # 5583505)। – Anna

+0

धन्यवाद। मुझे लगता है कि यह एक सटीक प्रति है। यदि मैं अन्य पोस्ट का समाधान चाहता हूं तो मैं शायद इस प्रश्न को हटा दूंगा। – Bahamut

+0

@ अन्ना करेनीना - क्या आप मुझे बता सकते हैं कि यह अभी भी नियमित कॉलआउट क्यों प्रदर्शित कर रहा है? मैंने अपना कोड – Bahamut

उत्तर

14

झपकी के कुछ मिनटों के बाद जवाब मिला।

गाइड के रूप में this का उपयोग कर, मैं सिर्फ

-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view 

जो एनोटेशन कॉल आउट से पता चलता ओवरराइड करने के लिए की जरूरत है। जवाब के लिए फिर से धन्यवाद, सुश्री अन्ना।

संबंधित मुद्दे