【发布时间】:2014-09-04 17:13:45
【问题描述】:
我的应用中有一张地图,其中显示了我自己项目的一些兴趣点。我没有使用默认的红色别针,但决定自己制作一个。此图钉工作正常,看起来很好,当我点击它时,我会看到标注气泡,但它没有在右侧显示默认的附件按钮。但是,它确实显示空白区域,表明它在那里,如果我将它从右向左更改,它确实会移动,但我看不到它。
正如你所看到的,我的气泡显然为按钮腾出了空间,当我点击按钮应该在的位置时,它实际上会运行我的
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
没有任何问题,所以附件按钮只是“隐藏”。
这是我用于默认注释视图的代码:
- (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.
【问题讨论】:
-
您是否在应用程序的任何位置设置了 tintColor(如 UIButton 外观)?
-
我的代码中没有提及 tintColor。但是,您的评论让我想知道是否可以将我的 annotationView 的 tintColor 更改为蓝色,以查看 tintColor 是否确实导致了问题(因为我只将它应用于我的 annotationView 它不会影响其他任何东西)和你猜怎么着...问题解决了!请重新写下您的评论作为答案,以便我接受。