简体   繁体   中英

UIView swipe gesture conflicts with tableview in objective c

I have more than 20 viewcontrollers in my project and added swipe gesture in global viewcontroller class.

UISwipeGestureRecognizer *rightSwipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(navigateToPreviousScreen:)];
rightSwipeGesture.cancelsTouchesInView = YES;
rightSwipeGesture.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:rightSwipeGesture]; 

And override all sub class

- (void)navigateToPreviousScreen:(UISwipeGestureRecognizer *)sender { 

[self.navigationController popViewControllerAnimated:YES];}

Now i got a problem (not exactly a problem), The some of the viewcontrollers has tableviews and that swipe is not work sometimes(also got some touch sensitive issue). Is there a way to solve it. I set cancelsTouchesInView = No but seems problem occurs.

Thanks in Advance.

You should be able to fix this by implementing & returning YES in the following UIGestureRecognizerDelegate method in the parent class.

  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
        return YES;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM