UIView——“启用用户交互"对父母是假的,但对孩子是真的? [英] UIView -- "user interaction enabled" false on parent but true on child?

查看:13
本文介绍了UIView——“启用用户交互"对父母是假的,但对孩子是真的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

父视图上的 userInteractionEnabled=NO 似乎会阻止用户在所有子视图上进行交互.这个对吗?有没有办法解决这个问题?

It appears that userInteractionEnabled=NO on a parent view will prevent user interaction on all subviews. Is this correct? Is there any way around this?

推荐答案

没错,在父视图上将 userInteractionEnabled 设置为 NO 将向下级联到所有子视图.如果您需要某些子视图启用交互,而不是其他,您可以将子视图分成两个父视图:一个 userInteractionEnabled = YES,另一个 NO.然后将这两个父视图放在主视图中.

That's correct, userInteractionEnabled set to NO on a parent view will cascade down to all subviews. If you need some subviews to have interaction enabled, but not others, you can separate your subviews into two parent views: one with userInteractionEnabled = YES and the other NO. Then put those two parent views in the main view.

这篇关于UIView——“启用用户交互"对父母是假的,但对孩子是真的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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