创建带有按钮的自定义呼出视图 [英] Creating Custom Call out View with button on it
问题描述
我陷入了过去三天一直在上网的地图视图问题,但仍然找不到合适的解决方案.
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.
推荐答案
在您的委托方法中
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
}
这篇关于创建带有按钮的自定义呼出视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!