Ios 带UIScreenedGegestureRecognitor的SWReveevalview控制器PangestureRecognitor
我一直在寻找这个问题的答案,但没有找到任何答案。所以我在我的项目中使用SWRevealViewController作为侧栏菜单,但我希望当用户开始从视图的左边缘触摸时,侧栏菜单会打开。我之所以要这样做,是因为我有另一个用于左右滑动的SwipegestureRecognitor。要添加左右滑动,我将使用以下代码:Ios 带UIScreenedGegestureRecognitor的SWReveevalview控制器PangestureRecognitor,ios,objective-c,swrevealviewcontroller,Ios,Objective C,Swrevealviewcontroller,我一直在寻找这个问题的答案,但没有找到任何答案。所以我在我的项目中使用SWRevealViewController作为侧栏菜单,但我希望当用户开始从视图的左边缘触摸时,侧栏菜单会打开。我之所以要这样做,是因为我有另一个用于左右滑动的SwipegestureRecognitor。要添加左右滑动,我将使用以下代码: UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc]initWithTarget:se
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipedToRight:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget: self action: @selector(swipedToLeft:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
所以我的问题是,如何才能使侧菜单仅在触摸从左边缘开始时打开
UPD 1
我使用此代码通过在屏幕的任何部分平移来打开侧菜单
[self.view addGestureRecognizer: self.revealViewController.panGestureRecognizer];
我有识别器可以向右滑动。问题是一旦它打开菜单并执行刷卡操作。我想允许打开菜单时,只有接触是从左边缘
UPD 2已解决
我通过设置可拖动边框宽度解决了此问题:
self.revealViewController.draggableBorderWidth = self.view.frame.size.width / 2;
现在,从边缘到中心的手势打开菜单,从中心到右边框执行滑动动作您可以如前所述添加UIPangestureRecognitor,或在视图顶部添加子视图并向其添加手势:
UIView *topView = ...
[self.view addSubview: topView];
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:@selector(didPan:)];
[topView addGestureRecognizer:pan];
我要做的是修改
UINavigationController
类中内置的已经存在的pop手势
要添加到视图中的示例代码将出现:
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
// Your code here
}
我要做的是修改内置于UINavigationController类中已经存在的pop手势