4

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?

BBog
  • 3,630
  • 5
  • 33
  • 64
Mapedd
  • 702
  • 7
  • 16
  • How about using single tap ...numberOfTapsRequired = 1 and using your button's frame etc. for each button that you want to use concurrently with other recognizers. – user523234 Sep 15 '11 at 13:32
  • found it [enter link description here][1] [1]: http://stackoverflow.com/questions/3344341/uibutton-inside-a-view-that-has-a-uitapgesturerecognizer – Mapedd Sep 16 '11 at 08:26

2 Answers2

3

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;
}
BBog
  • 3,630
  • 5
  • 33
  • 64
dengjiebin
  • 31
  • 1
  • 4
0

If you want to be able to click through something you can

.userInteractionEnabled = NO 
Fredrik
  • 1,282
  • 12
  • 15
  • yes, but i stil want to use UITapGestureRecognizer, if i make .setUserInteractionEnabled = NO i'm not able to receive events from UITapGR – Mapedd Sep 15 '11 at 09:39
  • but the recognizer is set on the UIVIew? That's why you should disable the interaction on the button, or maybe I'm missing something – Fredrik Sep 15 '11 at 10:00
  • the case is that UIView have UITapGR on it, and on top of that UIView i've got UIButton, and i need to use both things – Mapedd Sep 16 '11 at 08:03