替换 mkannotationview 中的 calloutaccessoryview
在我的 viewForAnnotation
委托中,我创建了一个 MKAnnotationView
,其中 leftCalloutaccessory
作为信息按钮。当点击信息按钮时,我想用 UIActivityIndicator
替换它。所以在 calloutAccessoryTapped 委托中,我写了 view.leftCalloutaccessoryView = [UIActivityIndicator IndicatorWithStyle:UIActivityIndicatorWhite];
标注附件似乎发生了变化,但视图似乎没有立即更新。
当标注配件被隐藏(通过点击另一个引脚)并重新打开时,我看到一个旋转器。但除此之外,我不这样做。
我也尝试调用 [view setNeedsdisplay]
和 [view setNeedsLayout]
和 [view layoutsubviews]
但徒劳。
有什么建议/指示吗?
In my viewForAnnotation
delegate, I create a MKAnnotationView
with leftCalloutaccessory
as a info button. When the info button is tapped, I want to replace it with a UIActivityIndicator
. So in the calloutAccessoryTapped
delegate, I wroteview.leftCalloutaccessoryView = [UIActivityIndicator indicatorWithStyle:UIActivityIndicatorWhite];
The callout accessory seems to change, but it seems like the view doesn't get updated immediately.
That's when the callout accessory gets hidden (by tapping another pin) and is re-opened, I see a spinner. But otherwise, I don't.
I tried calling [view setNeedsdisplay]
and [view setNeedsLayout]
and [view layoutsubviews]
as well but in vain.
Any suggestions/pointers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会考虑删除并重新添加您的注释。这看起来有点笨重,但可能有用。
I would consider removing and re-adding your annotation. It seems a little heavy handed, but might work.
我遇到了类似的问题 - 如果有与注释关联的图像,我需要为 leftCalloutAccessoryView 显示一张图像。尝试在mapView:didSelectAnnotationView而不是mapView:viewForAnnotation中设置它
I was having a similar problem -- I needed to display an image for the leftCalloutAccessoryView if there was one associated with the annotation. Try setting it in mapView:didSelectAnnotationView instead of in mapView:viewForAnnotation