viewForAnnotation 在 iPhone 4 中未调用,但在模拟器中工作
所以我遇到了最奇怪的问题,我已经去过所有看起来的地方。我遇到的问题是,我为 MKMapView 创建自定义注释视图。此 MKMapView 开始时没有注释,当您更改区域时,将创建注释并将其添加到地图中。调用 [my_map_view addAnnotation:a_annotation] 时;什么也没发生。 mapView viewForAnnotation 未被调用,并且没有任何内容显示。现在,iPhone4 就是这种情况,但是当我在模拟器上运行相同的代码时,它最终会工作。我想知道这是为什么?我认为这是地图部分的刷新问题,因为当我双击手机并且地图进行缩放处理时,注释就会显示出来。我知道你可以做一大堆 [my_map_view setRegion:my_map_view.currentRegion];并将中心设置为中心以尝试刷新我什至尝试将区域更改为不同的区域,但没有任何效果。任何想法,我都被难住了,过去三天我一直在努力解决这个问题。
So I am having the strangest problem and I have gone to every where it seem. What I am having an issue with is that I create custom annotation views for my MKMapView.This MKMapView starts with no annotations and as you change the region then annotation are created and added to the map. Upon calling [my_map_view addAnnotation:a_annotation]; Nothing happens. mapView viewForAnnotation is not called and there is nothing Displayed. Now, this is the case for the iPhone4 however when I run the same code on the simulator it ends up working. I am wondering why this is? I believe that it is a refresh problem on the maps part because when I double tap on the phone and the map does its zoom deal, the annotation shows up. I know that you can do a whole bunch of [my_map_view setRegion:my_map_view.currentRegion]; and setting the center with its center to try a refresh I have even tried changing the region to a different one however nothing works. Any Ideas, I am stumped and have been working on this for the past 3 days.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘿伙计们,我解决了问题所在。每当您在重新加载地图时遇到问题时,我发现最好的解决方案是销毁并创建地图以显示您的注释。因此,请确保从视图中删除地图,并将其设置为 nil,然后重新分配内存并使用注释数据对其进行初始化。抱歉没有发布代码,我必须清理很多数据名称,以便:( - 如果这个解决方案不起作用,请继续给我发一条消息,这样我就可以和你一起检查代码。如果有什么我可以随时做一个给你的例子:)这可能只是一段时间的工作原因。
这也是我对你们的 annot 方法的看法,因为我知道这是需要发布的:)
Hey guys so I fixed what the issue is. Whenever you have a problem reloading the map I found the best solution is to destroy and create the map in order to show your annotations. So make sure to remove the map from the view release it set it to nil and then reallocate the memory and initialize it with you annotation data. Sorry about not posting code I have to clean a lot of the data names in order to:( - If this solution doesnt work go ahead and shoot me a message so I can go through the code with you. If anything I can always make an example for you:) it just might be a while cause of work.
Also here is my view for annot method for you guys cause I know that that was wanted for posting :)