0

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

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:”

4

1 回答 1

0

方法名称是initWithAnnotation:reuseIdentifier:

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

MKPinAnnotationView *customPinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
                                                                     reuseIdentifier:@"identifier"];
于 2013-06-20T21:17:02.507 回答