All.
In my iOS 8.0 app.
In a Parent Child View architecture. By this code...
[self addChildViewController:slideTableViewController];
[self.view addSubview:slideTableViewController.view];
[slideTableViewController didMoveToParentViewController:self];
I have implemented TapGesturerecognizer & PanGesturerecognizer on Base View Controller.
So, that it can recognise Pan(Dragging) and Tap. I need both gestures on my BaseView.
Just do not want Tap Gesture on SlideView
.
As I want to execute didSelectRowAtIndexpath method on child view,
Solution:
Answer for Question 1: Many StackOverflow answers have the same funda.. Disable Tap gesture when your touch encounters child view.
if([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]){
if(CGRectContainsPoint(slideTableViewController.view.frame,[touch locationInView:self.view])){
return NO;
}
}
Answer for Question 2:
How to determine Is it a PanGesture or TapGesture ?
For each gesture type the delegate method will call
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
If you have implemented two gestures in your view, pan gesture and touch gesture,
This method will call 2 times, 1 time for pan gesture and 1 time for tap gesture.
So, in this method you can check like isKindOfClass
method.
Thank you very much for helping......
Just set tapGesture.cancelsTouchesInView = YES;
You can implement the gesture's delegate method in your baseViewController
:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizershouldReceiveTouch:(UITouch *)touch {
return touch.view == self.view;
}
OR //If it is a Tap Gesture and Your touch intersects with a perticular View, For that we have this method.
if([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]){
if(CGRectContainsPoint(slideTableViewController.view.frame,[touch locationInView:self.view])){
return NO;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With