【发布时间】:2015-10-28 07:00:51
【问题描述】:
我一直在寻找这个问题的解决方案,但没有找到任何解决方案。所以我在我的项目中使用 SWRevealViewController 作为侧边栏菜单,但我希望当用户从视图的左边缘触摸时,侧边菜单会打开。我想要这个,因为我有另一个用于左右滑动的 swipeGestureRecognizer。要添加左右滑动,我使用以下代码:
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;
现在从边缘到中心的手势打开菜单,从中心到右边框执行滑动操作
【问题讨论】:
标签: ios objective-c swrevealviewcontroller