使用 MapKit 接收 MKMapView 的 UIView 子视图的触摸时出现问题

发布于 2024-07-30 06:44:13 字数 229 浏览 5 评论 0原文

当按下按钮时,我已将 UIView 的子类添加为 MKMapView 的子视图。 UIView 的背景颜色设置为清晰。 此 UIView 不会收到任何 TouchBegan 等消息。 MKMapView 似乎仍在接收所有消息,因为双击时仍然会发生缩放等。

我如何确保子视图正在接收消息,并且有没有办法调试响应者链,以查看消息的位置发送。

谢谢。

如果您需要更多信息,请直接说。

I have added a subclass of UIView as a subview to an MKMapView when a button is pressed. The UIView has its background colour set to be clear. This UIView is not getting messaged with any of the touchesBegan, etc. messages. The MKMapView seems to be receiving all the messages still as zooming still occurs on a double click, etc.

How can I ensure that the subview is receiving the messages and is there a way to debug the responder chain, to see where the message is being sent.

Thanks.

If you need anymore information just say.

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

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

发布评论

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

评论(3

故乡的云 2024-08-06 06:44:13

谢谢回复。 我现在已经能够解决这个问题了。 问题是我将子视图添加到 MKMapView 而不是 ViewController 的视图。 我不知道为什么这是一个问题。 如果你这样做,我有兴趣听听。 将视图作为子视图添加到 ViewController 的视图中修复了所有问题,视图现在接受触摸,即使其颜色为 UIColor clearColor。

Thanks for the reply. I have been able to fix the problem now. The issue was that I was adding the subview to the MKMapView rather than the view of the ViewController. I don't know why this is an issue. If you do I would be interested to hear. Adding the view as a subview to the view of the ViewController fixed everything, with the view now accepting the touches, even when its colour is UIColor clearColor.

画尸师 2024-08-06 06:44:13

你有没有让你的 UIView 不透明? 因为如果是这样,并且您将其设置为透明,那么触摸将被下面的视图占据

Have you made your UIView opaque? Because if it is, and you made it transparent then the touches will be taken up by the view underneath

み零 2024-08-06 06:44:13

我刚刚从saimhann2002 那里找到了这个解决方案,他也遇到了类似的问题。

感谢您的回复。 我现在已经能够解决这个问题了。 问题是我将子视图添加到 MKMapView 而不是 ViewController 的视图。 我不知道为什么这是一个问题。 如果你这样做,我有兴趣听听。 将视图作为子视图添加到 ViewController 的视图中修复了所有问题,视图现在接受触摸,即使其颜色为 UIColor clearColor。

这样可行!

I just found this solution from saimhann2002 who was having a similar problem.

Thanks for the reply. I have been able to fix the problem now. The issue was that I was adding the subview to the MKMapView rather than the view of the ViewController. I don't know why this is an issue. If you do I would be interested to hear. Adding the view as a subview to the view of the ViewController fixed everything, with the view now accepting the touches, even when its colour is UIColor clearColor.

That works!

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