长按注解时,注解图像将被RedPushPin替换 [英] Annotation Image is replaced by RedPushPin when long press on annotation

查看:95
本文介绍了长按注解时,注解图像将被RedPushPin替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了带有以下内容的自定义注释:

I have created Custom Annotation with following:

-(MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 
{
    MKPinAnnotationView *view = nil;
    if (annotation != mapView.userLocation)
    {
        view = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"myAnnotationIdentifier"];
        if (!view) 
            view = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"myAnnotationIdentifier"];

        if (((CustomAnnotation *)annotation).annotationType == 1)
        {
            view.image = [UIImage imageNamed:@"type1.png"];
            view.rightCalloutAccessoryView = nil;
            view.canShowCallout = YES;
        }
        else
        {
            view.image = [UIImage imageNamed:@"type2.png"];
            view.rightCalloutAccessoryView = nil;
            view.canShowCallout = YES;
        }
    }
return view;
}

问题::当用户在任何注释图像(类型1或类型2)上按住2秒钟时,图像将被红色PushPin替换(iPhone MKPinAnnotationView的默认设置).

Problem: When User press and hold for 2 seconds on any Annotation Image (type1 or type2), Image gets replaced by Red PushPin(Default for iPhone MKPinAnnotationView).

我想避免这种替换.我该怎么办?

I want to avoid this replacement. How can I do so?

推荐答案

而不是声明并创建MKPinAnnotationView,而是声明并创建普通的MKAnnotationView.

Instead of declaring and creating an MKPinAnnotationView, declare and create a plain MKAnnotationView.

MKPinAnnotationView喜欢默认使用红色引脚,这就是它的用途.

The MKPinAnnotationView likes to default to the red pin which is what it's for.

这篇关于长按注解时,注解图像将被RedPushPin替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆