Did somebody ever override successfully the method setDragState
in MKAnnotationView
?
If I try to google for it with "mkannotationview setDragState
" I only get three hits! One of them is my other post on stackoverflow ;)
The reference says that when subclassing MKAnnotationView
the subclass has to care about the dragstate. But it does not say how to exactly. Only setting the dragstate to MKAnnotationViewDragStateDragging
or rather MKAnnotationViewDragStateCanceling
seems not to be enough. Because if I just do that, one of the issues for example is that the mapview does not receive the mapView:annotationView:didChangeDragState:fromOldState:
delegate function.
I tried to override it by setting the dragState also in the super class. But at this point other errors occur: For example if I drag the annotationView and my finger runs off the screen, the app crashes with something like "can not remove observer for keypath dragstate" (but my subclass does not any observers I know about). So it seems to that there are other things to care of.
In this post on apple developer forum https://devforums.apple.com/message/203107#203107 aroonicus, a guy from apple, mentions that you have to override [MKAnnotationView setDragState:] but sadly he does not tell how to.
Can anybody help? Does anybody know howto override setDragState? Did anybody created a working subclass of MKAnnotationView overriding setDragState?
Bye,
Ben
Refer this thread refer to the second answer where a custom annotation view class is used to override the existing one. It works
Subclassing MKAnnotationView and overriding setDragState
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With