试图自定义注释引脚

时间:2013-06-20 21:05:29

标签: ios mkmapview mkpinannotationview

我正在尝试为一些现有代码添加一个标注附件。 这是我的注释主要代码:

OTNVenueAnnotation *annotation = [[OTNVenueAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(location.latitude, location.longitude);
annotation.title = [[venue objectForKey:@"name"] uppercaseString];
annotation.venue = venue;

MKPinAnnotationView* customPinView = [[MKPinAnnotationView alloc]
                                      initWithAnnotation:annotation];

UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        [rightButton addTarget:self
                        action:@selector(showDetails:)
              forControlEvents:UIControlEventTouchUpInside];
        customPinView.rightCalloutAccessoryView = rightButton;   

[self.mapView addAnnotation: annotation];

构建错误是:  'MKPinAnnotationView'没有可见的@interface声明选择器'initWithAnnotation:'

1 个答案:

答案 0 :(得分:0)

方法名称为initWithAnnotation:reuseIdentifier:

您需要在初始化时使用NSString作为重用标识符参数提供注释视图。

MKPinAnnotationView *customPinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
                                                                     reuseIdentifier:@"identifier"];
相关问题