3

我将 SWRevealViewController 用于侧边栏,我必须对上一个和下一个故事使用滑动,对侧边栏使用边缘平移。

我使用 UIScreenEdgePanGestureRecognizer 而不是 PanGestureRecogniser 的原因是因为滑动最终会调用平移手势,这会导致整个页面一团糟。我希望有一种方法可以在边缘平移识别器激活而不是使用它时调用平移手势:

[self.view addGestureRecognizer:[MainViewController sharedInstance].revealViewController.panGestureRecognizer];


[[BTHomeViewController sharedInstance].revealViewController.panGestureRecognizer requireGestureRecognizerToFail: left];
[[BTHomeViewController sharedInstance].revealViewController.panGestureRecognizer requireGestureRecognizerToFail: right];

我想使用 SWRevealVC 的委托。如果有其他方法,请给我建议。

UIScreenEdgePanGestureRecognizer *panLeft = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(_handleRevealGesture:)];
[panLeft setEdges:UIRectEdgeLeft];
panLeft.minimumNumberOfTouches = 1;
panLeft.maximumNumberOfTouches = 1;
[self.view addGestureRecognizer:panLeft];

SWRevealVC 的委托方法

// The following methods provide a means to track the evolution of the gesture recognizer.
// The 'location' parameter is the X origin coordinate of the front view as the user drags it
// The 'progress' parameter is a positive value from 0 to 1 indicating the front view location relative to the
// rearRevealWidth or rightRevealWidth. 1 is fully revealed, dragging ocurring in the overDraw region will result in values above 1.
- (void)revealController:(SWRevealViewController *)revealController panGestureBeganFromLocation:(CGFloat)location progress:(CGFloat)progress;
- (void)revealController:(SWRevealViewController *)revealController panGestureMovedToLocation:(CGFloat)location progress:(CGFloat)progress;
- (void)revealController:(SWRevealViewController *)revealController panGestureEndedToLocation:(CGFloat)location progress:(CGFloat)progress;
4

1 回答 1

5

用 UIScreenEdgePanGestureRecognizer 替换 UIPanGestureRecognizer 只需这样做:

  • 转到 SWRevealViewController
  • 使用 UIScreenEdgePanGestureRecognizer 查找并替换 UIPanGestureRecognizer
  • 最重要的设置边缘

    _panGestureRecognizer.edges = UIRectEdgeLeft;

于 2015-03-05T14:41:16.027 回答