tapGesture.delegate = self; - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { CGPoint location = [touch locationInView:self.view]; if(CGRectContainsPoint(button.frame, location)) { return NO; } return YES; }
响应如上委托方法,判断,手势的触击方法是否在按钮区域,如果是,则返回NO,禁用手势。否则返回YES