On iOS, if a superview#39;s userInteractionEnabled is NO, then all subviews are disabled as well?(在 iOS 上,如果 superview 的 userInteractionEnabled 为 NO,那么所有子视图也会被禁用吗?)
问题描述
我认为当一个视图被触摸或点击时,它的处理程序首先被调用,然后它的父视图的处理程序被调用(向上传播).
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 be active
所以你当前的主视图和你当前的子视图将成为兄弟,新容器视图的子视图
So your current main view and you current subviews will become siblings, children of a new container view
这篇关于在 iOS 上,如果 superview 的 userInteractionEnabled 为 NO,那么所有子视图也会被禁用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 iOS 上,如果 superview 的 userInteractionEnabled 为 NO,那么所有子视图也会被禁用吗?
基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
