【问题标题】:trying to customise annotation pin尝试自定义注释引脚
【发布时间】:2013-06-20 21:05:29
【问题描述】:

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

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

【问题讨论】:

    标签: ios mkmapview mkpinannotationview


    【解决方案1】:

    方法名是initWithAnnotation:reuseIdentifier:

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

    MKPinAnnotationView *customPinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
                                                                         reuseIdentifier:@"identifier"];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-06
      • 1970-01-01
      • 2016-12-08
      • 1970-01-01
      • 2016-03-20
      • 1970-01-01
      • 2012-01-05
      • 1970-01-01
      相关资源
      最近更新 更多