问题描述
在iOS7中,我们有一个新的向左滑动手势,这是一个非常有用的功能,但现在我遇到了问题。
In iOS7, we have a new "swipe left to right" gesture, this is a very useful feature, but now I have a problem with it.
I使用此代码自定义 UINavigationBar
中的后退按钮。
I use this code to custom the back button in UINavigationBar
.
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:view];
但是这将禁用从左向右滑动手势,所以我使用按照代码保持手势启用。
but this will disables the "swipe left to right" gesture, so I use the follow code to keep the gesture enabled.
self.navigationController.interactivePopGestureRecognizer.delegate = self
然后,我发现手势工作异常,如果当前的ViewController有一个tableView,当tableView滚动时,手势将不会被触发。现在手势无法轻易触发,是否有某种方法可以修复它?
And then, I found that the gesture is working abnormal, if current ViewController has a tableView, when the tableView is scrolling, the gesture won't be triggered. Now the gesture can't be triggered easily, is there some way to fix it?
推荐答案
此代码对我来说很好。
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return [gestureRecognizer isKindOfClass:UIScreenEdgePanGestureRecognizer.class];
}
这篇关于UINavigationController interactivePopGestureRecognizer在iOS7中工作异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!