如何判断 MKMapView 和可见的 MKAnnotationView 何时完成绘制?

发布于 2024-09-30 12:56:22 字数 384 浏览 0 评论 0原文

我正在显示一个带有 MKAnnotations 的 MKMapView,其中一些已被选中并显示其注释。 我正在尝试使用 -renderInContext 获取显示的地图和注释的图像。

90% 的情况下,地图、MKPinAnnotationView 和选定的注释都会被正确捕获。 另外 10% 的情况下,图像会丢失某些内容,通常是 MKPinAnnotationViews 或其注释(如果选择)。

我添加了代码来处理地图本身加载其地图数据。

但我无法找到一些东西来向我表明所有可见的 MKPinAnnotationView 都已绘制 如果选择,则显示其注释?

我遇到的最接近的提示是 addObserver,尽管我还没有弄清楚可以观察到什么来告诉我何时完成所有绘图。

想法?

I'm displaying a MKMapView with MKAnnotations some of which are selected and showing their Annotation.
I am trying to grab an image of the displayed map and annotations using the -renderInContext.

90% of the time the Map, MKPinAnnotationView's and selected annotations are correctly captured.
The other 10% of the time the image is missing something, usually the MKPinAnnotationViews or their annotations if selected.

I've added code to deal with the Map itself loading it's map data.

But I haven't been able to track down something that would indicate to me that all of the visible MKPinAnnotationView's have been drawn
and if selected their annotations displayed??

the closest hint I've come across is the addObserver, although I haven't figured out what could be observed that would tell me when all of the drawing is done.

Thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谈下烟灰 2024-10-07 12:56:22

好吧我是个白痴...
我终于找到了问题所在。在 MKMapView 委托协议中的 viewForAnnotation 例程中,我没有正确设置重用的 MKPinAnnotationView 的值。
因此,有时我会重用 .canShowCallout 设置为 YES 的视图,而有时我会重用 .canShowCallout 设置为 NO 的视图。

.<

ok I'm an idiot...
I finally tracked down the problem. In my viewForAnnotation routine in the MKMapView Delegate protocol I wasn't correctly setting values for reused MKPinAnnotationView's.
So some of the time I would reuse a view that had .canShowCallout set to YES and other times I'd reuse a view that had .canShowCallout set to NO.

.<

我不会写诗 2024-10-07 12:56:22

尝试使用 MKMapViewDelegate didAddAnnotationViews 方法。

如果在该方法中,绘图仍未准备好满足您的要求,您可以在其中使用 PerformSelector:withObject:afterDelay: 调用捕获方法。

Try using the MKMapViewDelegate didAddAnnotationViews method.

If in that method, the drawing is still not ready for your requirements, you could then in there call your capturing method with performSelector:withObject:afterDelay:.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文