[英]Disable Root view interaction and Enable subview interaction at a time
I am developing an app.I have used a view and added a subview to that.My question is when click on a button in root view I added a sub view(tableview). 我正在开发一个应用程序。我使用了一个视图并添加了一个子视图。我的问题是当在根视图中单击按钮时我添加了一个子视图(tableview)。 And when i select any row in table view.then removing the view from super view.when I added the subview to root view..I want to disable root view interaction without effecting the subviews interaction.
当我在表视图中选择任何行时,然后从超级视图中删除视图。当我将子视图添加到根视图时..我想禁用根视图交互而不影响子视图交互。 Is is possible?
有可能吗?
放置一个透明或半透明的叠加视图(Alpha = 0到0.5),在根视图的顶部有frame = rootView.frame,然后将你的表视图放入这个叠加视图,没有触摸事件可以通过,呵呵。
The value of userInteractionEnabled
affects all subviews of the view it's set to, so no, not in the way you're thinking. userInteractionEnabled
的值会影响它设置的视图的所有子视图,所以不,不是你想的那样。 If you wish to disable touch events for a view, subclass it and override - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
to forward it's touches to the other view. 如果您希望禁用视图的触摸事件,请将其子类化并覆盖
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
以将其触摸转发到另一个视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.