本文介绍了当我尝试拖动时,自定义MKAnnotation图像会恢复为默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆不需要拖动的MKA注释.我用[pin setDraggable:NO]设置.当我触摸注释并(偶然)拖出注释时遇到问题,它会立即失去其自定义图像并变回默认的红色图钉.如何防止这种情况发生?

I've got a bunch of MKAnnotations that don't need dragging. I set this by [pin setDraggable:NO]. I'm having an issue when I touch the annotation and (accidentally) drag off an annotation, it instantly looses it's custom image and changes back to the default red pin. How do I prevent this from happening?

推荐答案

在viewForAnnotation委托方法中, 确保将视图创建为MKAnnotationView ,而不是MKPinAnnotationView (这是MKAnnotationView的子类,该子类会自动提供固定图片).

In the viewForAnnotation delegate method, make sure the view is created as an MKAnnotationView and not an MKPinAnnotationView (which is a subclass of MKAnnotationView that automatically provides a pin image).

这篇关于当我尝试拖动时,自定义MKAnnotation图像会恢复为默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 10:14