在iOS上,如果superview的userInteractionEnabled为NO,那么所有子视图也会被禁用? [英] On iOS, if a superview's userInteractionEnabled is NO, then all subviews are disabled as well?

查看:894
本文介绍了在iOS上,如果superview的userInteractionEnabled为NO,那么所有子视图也会被禁用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为当触摸或点击视图时,首先调用其处理程序,然后调用其superview的处理程序(向上传播)。

I thought when a view is touched or tapped on, its handler get called first, and then its superview's handler is called (propagate upward).

但是它是如果超级视图的 userInteractionEnabled 设置为NO,那么所有子视图和后代也会被禁用以进行用户交互?如果我们只想禁用主视图但又不想禁用子视图怎么办?

But is it true that if the superview's userInteractionEnabled is set to NO, then all subviews and offspring is also disabled for user interaction? What if we want to disable for just the main view but don't want to disable for the subviews?

推荐答案

你不能做什么那,

相反,你会改变你的观点的安排如下:

Instead you would change the arrangment of your views like following:

Main View-> subViews

Container View -> Main View that you want to set as inactive
               -> other views that you want to still active

因此,您当前的主视图和当前的子视图将成为兄弟姐妹,新容器视图的子项

So your current main view and you current subviews will become siblings, children of a new container view

这篇关于在iOS上,如果superview的userInteractionEnabled为NO,那么所有子视图也会被禁用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆