简体   繁体   English

UIView滑动手势与目标c中的tableview冲突

[英]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. 我的项目中有20多个ViewController,并在全局ViewController类中添加了滑动手势。

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. 我设置cancelsTouchesInView = No,但似乎出现了问题。

Thanks in Advance. 提前致谢。

You should be able to fix this by implementing & returning YES in the following UIGestureRecognizerDelegate method in the parent class. 您应该能够通过在父类的以下UIGestureRecognizerDelegate方法中实现并返回YES来解决此问题。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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