我的应用程序中有一张 map ,其中显示了我自己项目的一些兴趣点。我没有使用默认的红色图钉,而是决定自己制作一个。这个图钉工作正常,看起来很好,当我点击它时,我得到了标注气泡,但它没有在右侧显示默认的 accessorybutton。但是,它确实会显示空白区域,表明它在那里,如果我将它从右移到左,它实际上会移动,但我看不到它。
正如您所看到的,我的气泡显然为按钮腾出了空间,当我点击按钮应该在的位置时,它实际上会运行我的
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
没有任何问题,所以附件按钮只是“隐藏”了。
这是默认注释 View 的代码:
- (MKAnnotationView *)annotationView {
MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:self reuseIdentifier:@"PlaceAnnotation"];
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.image = [UIImage imageNamed:@"annotationPin"];
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.centerOffset = CGPointMake(0, -annotationView.image.size.height / 2);
return annotationView;
这是我的 MapViewController 本身的代码:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
if ([annotation isKindOfClass:[PlaceAnnotation class]]) {
PlaceAnnotation *placeAnnotation = (PlaceAnnotation *)annotation;
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"PlaceAnnotation"];
if (annotationView == nil) {
annotationView = placeAnnotation.annotationView;
} else {
annotationView.annotation = annotation;
}
return annotationView;
} else {
return nil;
}
我是不是认为
.rightCalloutAccessoryView = ...
是让按钮显示的唯一一行吗?我只想要文本旁边中间带有 i 的默认蓝色圆圈,这样我的用户就可以清楚地知道他们可以点击气泡。
S.
最佳答案
尚不清楚为什么您的辅助按钮是“不可见的”,但标准 UIButton
受 tintColor
设置的影响。
尝试在注释 View 上显式设置 tintColor
:
annotationView.tintColor = [UIColor blueColor];
关于ios - 标注附件按钮显示,但不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25671356/