13
我在我的应用程序地图页面中有一个需求。我必须自定义标注泡泡。我需要添加一个图像,两个标签和一个具有特定高度和宽度的按钮。自定义MKAnnotation标注气泡
我已经通过网络,找不到解释如何自定义标注泡泡的正确链接。如果您有任何人遇到或知道它,请与我分享。
任何简单的例子或链接将是非常好的。
在此先感谢 苏雷什
我在我的应用程序地图页面中有一个需求。我必须自定义标注泡泡。我需要添加一个图像,两个标签和一个具有特定高度和宽度的按钮。自定义MKAnnotation标注气泡
我已经通过网络,找不到解释如何自定义标注泡泡的正确链接。如果您有任何人遇到或知道它,请与我分享。
任何简单的例子或链接将是非常好的。
在此先感谢 苏雷什
一个例子,以帮助您:
- (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;
}
的
可能重复[?定制annotationview标注泡]( http://stackoverflow.com/questions/1565828/customize-callout-bubble-for-annotationview) – Anurag 2010-11-04 06:21:41
嗨anurag 该帖子没有帮助我。因为在哪里写openForAnnotation事件以及当我单击注释时如何连接视图。我不清楚。我正在寻找更详细的解释。如果你知道,请... – sbmandav 2010-11-04 06:52:37