开发者

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 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜