我的应用程序地图页面中有一个要求。我必须自定义标注气泡。我需要添加一个图像、两个标签和一个具有特定高度和宽度的按钮。
我浏览了网页,找不到解释如何自定义标注气泡的正确链接。如果你们中的任何人遇到或知道它,请与我分享。
任何简单的示例或链接都会非常棒。
在此先感谢
我的应用程序地图页面中有一个要求。我必须自定义标注气泡。我需要添加一个图像、两个标签和一个具有特定高度和宽度的按钮。
我浏览了网页,找不到解释如何自定义标注气泡的正确链接。如果你们中的任何人遇到或知道它,请与我分享。
任何简单的示例或链接都会非常棒。
在此先感谢
一个帮助你的例子:
- (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;
}
有关更多信息,请查看:http: //developer.apple.com/library/ios/#documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html%23//apple_ref/occ/cl/MKAnnotationView