I have a scroll view and a button placed over it , When i add a tap gesture recognizer the button does not work. Is there any way of limiting the tap only to scroll view and not to the button, so that the button functions normally.
here is my code
UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)];
tap.numberOfTapsRequired = 1;
tap.numberOfTouchesRequired = 1;
[scroll addGestureRecognizer:tap];
[tap release];
- (void)tapGesture:(UIGestureRecognizer*)gesture{
NSLog(@"scroll tapped");
}
If you do
It will allow button to be pressed. However taps will be detected along with the button press when you press a button. Do avoid this, you will have to subclass
UIScrollViewand implement the following method –Implementing the method above pass the touches to the scroll view’s subviews.