userInteractionEnabled

userInteractionEnabled

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

问题描述

父视图上的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设置为否在父视图将级联所有子视图。如果你需要一些子视图来启用交互,而不是其他的,你可以将你的子视图分成两个父视图:一个与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 - “启用用户交互” false对父,但对孩子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 04:30