Reputation: 3451
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?
Upvotes: 4
Views: 470
Reputation: 3872
try
tap.cancelsTouchesInView = NO;
or
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if([touch.view isKindOfClass:[UIButton class]])
return NO;
return YES;
}
Upvotes: 6