UIButtons won't work after UITapGestureRecognizer is added
ios, objective-c, uitapgesturerecognizer, xcode
Solution
try
tap.cancelsTouchesInView = NO;
or
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if([touch.view isKindOfClass:[UIButton class]])
return NO;
return YES;
}
Problem
I have the following code where i add UITapGestureRecognizer to my view: ``` UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(userTapped)]; [self.view addGestureRecognizer:tap]; ``` My problem is that when I press other `UIButton`s (buttons were created in IB) that are on the same view as the `UITapGestureRecognizer`, nothing happens. I suppose that i add to gestureRecognizer only one action (userTapped:), but how to add interaction with other buttons that were created?