objective c 中的 UIView 滑动手势与 tableview 冲突
UIView swipe gesture conflicts with tableview in objective c
我的项目中有20多个viewcontrollers并且在全局中添加了滑动手势viewcontroller class.
UISwipeGestureRecognizer *rightSwipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(navigateToPreviousScreen:)];
rightSwipeGesture.cancelsTouchesInView = YES;
rightSwipeGesture.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:rightSwipeGesture];
并覆盖所有子class
- (void)navigateToPreviousScreen:(UISwipeGestureRecognizer *)sender {
[self.navigationController popViewControllerAnimated:YES];}
现在我遇到了一个问题(不完全是一个问题),viewcontroller 中的一些有 tableviews 并且滑动有时不起作用(也有一些触摸敏感问题)。有办法解决吗。我设置了 cancelsTouchesInView = No,但似乎出现了问题。
提前致谢。
您应该能够通过在父 class.
的以下 UIGestureRecognizerDelegate
方法中实施并返回 YES 来解决此问题
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
我的项目中有20多个viewcontrollers并且在全局中添加了滑动手势viewcontroller class.
UISwipeGestureRecognizer *rightSwipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(navigateToPreviousScreen:)];
rightSwipeGesture.cancelsTouchesInView = YES;
rightSwipeGesture.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:rightSwipeGesture];
并覆盖所有子class
- (void)navigateToPreviousScreen:(UISwipeGestureRecognizer *)sender {
[self.navigationController popViewControllerAnimated:YES];}
现在我遇到了一个问题(不完全是一个问题),viewcontroller 中的一些有 tableviews 并且滑动有时不起作用(也有一些触摸敏感问题)。有办法解决吗。我设置了 cancelsTouchesInView = No,但似乎出现了问题。
提前致谢。
您应该能够通过在父 class.
的以下UIGestureRecognizerDelegate
方法中实施并返回 YES 来解决此问题
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}