13

I have a requirement in my application map page. I have to customize the Callout bubbles. I need to add an image, two labels and a button with specific height and width of each.

I have gone through web and could not find a proper link that explains how to customize the callout bubbles. If any one of you come across or know about it please share with me.

any simple examples or links would be really great.

Thanks in advance suresh

MathieuF
  • 3,130
  • 5
  • 31
  • 34
sbmandav
  • 1,211
  • 3
  • 16
  • 25
  • possible duplicate of [customize callout bubble for annotationview?](http://stackoverflow.com/questions/1565828/customize-callout-bubble-for-annotationview) – Anurag Nov 04 '10 at 06:21
  • hi anurag that post did not help me. since where to write openForAnnotation event and how to hook up the view when i click on annotation. It was not clear for me. I am looking for more detailed explanation on that. if you know, pls.. – sbmandav Nov 04 '10 at 06:52

1 Answers1

21

An example to help you :

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{   
    MKAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"loc"];

    // Button
    UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    button.frame = CGRectMake(0, 0, 23, 23);
    annotationView.rightCalloutAccessoryView = button;

    // Image and two labels
    UIView *leftCAV = [[UIView alloc] initWithFrame:CGRectMake(0,0,23,23)];
    [leftCAV addSubview : yourImageView];
    [leftCAV addSubview : yourFirstLabel];
    [leftCAV addSubview : yourSecondLabel];
    annotationView.leftCalloutAccessoryView = leftCAV;

    annotationView.canShowCallout = YES;

    return annotationView;
}

For more informations, look at this : http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html%23//apple_ref/occ/cl/MKAnnotationView

civiac
  • 279
  • 4
  • 20
MathieuF
  • 3,130
  • 5
  • 31
  • 34