简体   繁体   English

iOS-通过地图视图禁用触摸

[英]iOS - disable touches through a view on map

I'm trying to disable touches through views on the map. 我正在尝试通过地图上的视图禁用触摸。 Right now when I touch a view it's transferring the touch through to the map. 现在,当我触摸视图时,它会将触摸传递到地图上。 Can anyone help? 有人可以帮忙吗?

You could try and disable userInteraction on all the subviews of your view. 您可以尝试在视图的所有子视图上禁用userInteraction。

NSArray *subviews = yourView.subviews;

for (UIView *view in subviews) {
    [view setUserInteractionEnabled:NO];
}

I haven't tested with a mapview, but I've used this setup before to disable touches on whole views and just re-enable touch for the couple of items I want (read-only mode basically). 我尚未使用mapview进行测试,但是我之前曾使用此设置来禁用整个视图上的触摸,而只是为我想要的几项重新启用触摸(基本上是只读模式)。 Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM