ios – 自定义MKAnnotation标注泡沫

我的应用程序地图页面中有一个要求.我必须自定义Callout泡泡.我需要添加一个图像,两个标签一个具有特定高度和宽度的按钮.

我已经通过网络,找不到一个适当的链接,解释如何自定义标注泡沫.如果您有任何人遇到或知道,请与我分享.

任何简单的例子或链接都将是非常好的.

提前致谢
苏雷什

解决方法

一个帮助你的例子:
- (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,23,23);
    annotationView.rightCalloutAccessoryView = button;

    // Image and two labels
    UIView *leftCAV = [[UIView alloc] initWithFrame:CGRectMake(0,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

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...