Reputation: 5208
Hi I have a UIView who's alpha is 0.7 and below it are some UITextFields. I don't want it to call touches events while keeping touches events. I tried using
[lightBoxView setUserInteractionEnabled:NO];
But now the UITextFields can become active or first responder. How can I disable it from calling touch events as well as not passing touches to others?
Upvotes: 0
Views: 388
Reputation: 13222
You also need to set the userInteractionEnabled = NO
for all the subviews as well.
Try this,
[[lightBoxView subviews] makeObjectsPerformSelector:@selector(setUserInteractionEnabled:)
withObject:[NSNumber numberWithBool:NO]];
This will call setUserInteractionEnabled:
on all direct subviews of lightBoxView
and set it to NO
. For a more complex subview hierarchy you will have to recursively loop through all the child views and disable the user interaction on each one. For this you can write a recursive method in a UIView
category. For more details about this category method take a look at this answer.
Hope that helps!
Upvotes: 1
Reputation: 4279
You can remove those control from tough gesture delegate method.
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([touch.view isKindOfClass:[UITextFiled class]])
{
return NO;
}
else
{
return YES;
}
}
Upvotes: 1