MKMapView RegionDidChangeAnimated 并不总是被调用!
这让我很沮丧!
大多数时候它都会被调用,但随后它就会停止响应捏合。它将在屏幕旋转和双击上调用。不至于紧要关头!
帮助!
This is frustrating me!!!
It will be called most of the time but then it stops responding to the pinches. It will be called on a screen rotate and a double tap. Not to a pinch!
Help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我正在处理一些具有相同问题的代码,结果发现问题是带有
UIGestureRecognizer
的子视图已作为子视图添加到MKMapView
中,有时,他们会导致某些委托方法不触发。因此,请确保您没有向 MKMapView 添加子视图或任何内容。
希望这有帮助。
I was working on some code that had the same issue and turns out the problem was a subview with a
UIGestureRecognizer
had been added as a subview toMKMapView
, and sometimes, they would cause some delegate methods not to fire.So make sure you aren't adding subviews or anything to the
MKMapView
.Hope this helps.
我正在用代码移动地图,然后看来我需要调用
After!
I was moving the map in code and then it appears I needed to call
After!
我认为这个问题可能与多线程有关。
今天早上我也遇到了同样的问题。我使用手势识别器来捕获长按事件,然后将图钉添加到地图视图。如果运行良好,但经过几轮后,该区域确实发生了更改方法停止被调用。
我在这里尝试了一些解决方案,但没有一个有效。然后我想起了之前遇到的关于操作的多线程性质的其他问题。因此,我尝试将长按操作中控制地图视图的代码移动到在主线程中运行的块。问题就解决了。
I think this problem may have something to do with multi-threading.
I had the same problem this morning. I use a gesture recognizer to capture long press event and then add a pin to the mapview. If works well but after a few rounds, the region did change method stop being called.
I tried a few solutions here but none works. Then I recalled some other issue I had before with multi-threading nature of actions. So I try to moved the code that controls the mapview in long press action to a block that runs in main thread. And the problem is solved.
我设法通过禁用touchesBeganCallback中的手势识别器
并在regionDidChangeAnimated委托方法中重新启用它来解决这个问题
I managed to solve this problem by disabling the gesture recognizer within the touchesBeganCallback
and reenabling it in the regionDidChangeAnimated delegate method
每当点击手势识别器添加到地图视图时,
如果您的业务逻辑允许在触摸地图视图时进行双重处理(通过 MKMapView 和手势识别器),则设置会解决问题
最近干扰该区域的[Will,Did]ChangeAnimated:)
Whenever a tap gesture recognizer added to the mapview, setting
takes care of the problem if your business logic allows for double processing if touches on mapview (by MKMapView AND the gesture recognizer
that was most recently interfering with the region[Will,Did]ChangeAnimated:)