gpt4 book ai didi

iphone - 子类 MKAnnotationView

转载 作者:可可西里 更新时间:2023-11-01 04:44:52 27 4
gpt4 key购买 nike

有没有人成功覆盖MKAnnotationView中的方法setDragState?如果我尝试使用“mkannotationview setDragState”在谷歌上搜索它,我只会得到三个结果!其中之一是我在 stackoverflow 上的另一篇文章;)

引用资料说,当子类化 MKAnnotationView 时,子类必须关心 dragstate。但它没有说具体如何。仅将 dragstate 设置为 MKAnnotationViewDragStateDragging 或者 MKAnnotationViewDragStateCanceling 似乎还不够。因为如果我只是这样做,其中一个问题是 mapview 没有收到 mapView:annotationView:didChangeDragState:fromOldState: 委托(delegate)函数。

我试图通过也在父类(super class)中设置 dragState 来覆盖它。但此时会出现其他错误:例如,如果我拖动 annotationView 并且我的手指离开屏幕,应用程序会崩溃,并出现类似“无法删除键路径拖动状态的观察者”(但我的子类没有我知道的任何观察者) .看来还有别的事要操心。

在苹果开发者论坛上的这篇帖子中 https://devforums.apple.com/message/203107#203107 aroonicus,一个来自 apple 的人,提到你必须覆盖 [MKAnnotationView setDragState:] 但遗憾的是他没有告诉如何去做。

有人可以帮忙吗?有人知道如何覆盖 setDragState 吗?有人创建了 MKAnnotationView 的工作子类来覆盖 setDragState 吗?

再见,

最佳答案

引用这个话题请参阅第二个答案,其中使用自定义注释 View 类来覆盖现有注释 View 类。有效

Subclassing MKAnnotationView and overriding setDragState

关于iphone - 子类 MKAnnotationView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3716061/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com