问题
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.
回答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
}
来源:https://stackoverflow.com/questions/7978598/creating-custom-call-out-view-with-button-on-it