【问题标题】:Avoid to display callout when a MKAnnotation is tapped避免在点击 MKAnnotation 时显示标注
【发布时间】:2014-05-21 09:22:19
【问题描述】:

我想避免在我点击 MKAnnotation 时显示标注,只是为了显示图钉,而当我点击时,我不想发生任何事情。

谢谢

【问题讨论】:

标签: ios iphone objective-c


【解决方案1】:

像这样试试。

 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"sample"];

    annView.canShowCallout = NO;

    return annView;
}

希望这段代码对你有用。

【讨论】:

  • 是的,我在等待时间限制:P。谢谢,效果很好
【解决方案2】:

这将对您有所帮助。

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
    static NSString *reuseId = @"pin";
    MKPinAnnotationView *pinV = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:reuseId];
    if (pinV == nil)
    {
        pinV = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseId];
        pinV.canShowCallout = NO; // You have to add this.
    }
    return pinV;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多