首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >正在尝试自定义注解别针

正在尝试自定义注解别针
EN

Stack Overflow用户
提问于 2013-06-21 05:05:29
回答 1查看 82关注 0票数 0

我正在尝试将标注附件添加到一些现有代码中。下面是我的注释主代码:

代码语言:javascript
复制
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‘没有可见的@接口声明了选择器'initWithAnnotation:’

EN

回答 1

Stack Overflow用户

发布于 2013-06-21 05:17:03

方法名为initWithAnnotation:reuseIdentifier:

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

代码语言:javascript
复制
MKPinAnnotationView *customPinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
                                                                     reuseIdentifier:@"identifier"];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17223757

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档