UIButton on top of UIView with UITapGestureRecognizer doesn't work
As in the title, I have an UIView sublcass with UITapGR added to it.
In the subclass of this class I'm laying few UIButtons on top of the view. UIButton won't receive any touches. When i tried to see [[tapGR view] class] it was UIButton's parent view. Calling setCancelsTouchesInView to NO won't help either.开发者_开发百科
Any ideas?
You can use this code to ignore the touch event for the UIButton:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([touch.view isKindOfClass:[UIButton class]]){
return NO;
}
return YES;
}
If you want to be able to click through something you can
.userInteractionEnabled = NO
加载中,请稍侯......
精彩评论