0

我遇到了地图查看问题,过去三天我一直在上网,但仍然没有找到任何合适的解决方案。

我的问题是当我单击自定义的图钉时,会出现一个标注。但标准标注仅支持两行文本。在我的情况下,我必须使用按钮显示四行文本。请任何人告诉我如何创建自定义标注或我应该使用什么方法,因为无法修改标准标注。

任何建议将不胜感激。提前致谢。

4

1 回答 1

1

在您的委托方法中

- (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

}
于 2011-11-02T10:50:44.710 回答