on one viewController i have one mainView, on that view i have one another view (which is known as sidePanel view having frame 0,0,86,420.)I have added tapGesture. Now i want to just enable gesture recognition only for mainView other than sidePanelView.
see below image
i want to disable tapGesture for sidePanelView & enable for area other than it. How to do it. (one thing i want to say area other than sidePanelView is parentView of sidePanelView).
You should accept Bharat's answer because that is correct. I only want to illustrate how you do it:
Define your view controller as conforming to UIGestureRecognizerDelegate
, e.g.:
@interface ViewController () <UIGestureRecognizerDelegate>
// the rest of your interface
@end
Make sure you set the delegate
for the gesture:
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleMainTap:)];
gesture.delegate = self;
[self.view addGestureRecognizer:gesture];
Then have and then check to see if the touch takes place for the view in question:
- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if (CGRectContainsPoint(self.menuView.bounds, [touch locationInView:self.menuView]))
return NO;
return YES;
}