0

I am stuck with a map View problem for which I was surfing the internet from the last three days but still not find any appropiate solution.

My problem is When I click on my pin which is customized, a callout appears. But standard callout support only two lines text.In my case I have to show four lines text with a button. Please any one tell me how to create a custom callout or what approach should I use as there is no way to modify the standard callout.

Any suggestions would be highly appreciated. Thanks in advance.

Gypsa
  • 11,230
  • 6
  • 44
  • 82

1 Answers1

1

In your delegate method

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKAnnotationView* annotationView = nil;

    //your code

        UIView *vw = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
        vw.backgroundColor = [UIColor redColor];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 50, 50)];
        label.numberOfLines = 4;
        label.text = @"hello\nhow are you\nfine";
        [vw addSubview:label];
        annotationView.leftCalloutAccessoryView = vw;
        return annotationView

}
Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
  • Hi thanks for your answer but this will create a problem that if I added three strings in view then title will be nil and calout will not appear. – Gypsa Nov 02 '11 at 10:56
  • That's why I have added space, it's not empty string – Inder Kumar Rathore Nov 02 '11 at 11:40
  • I think left and right CalloutAccessoryView will not work because if our view height is more than 32 then that background view of callour does not increased.Please suggest something else. – Gypsa Nov 02 '11 at 11:46
  • @Gypsa Did you get solution for this...then please post it...I am in same situation – vivek bhoraniya Nov 27 '13 at 13:56