繁体   English   中英

UIScreenEdgePanGestureRecognizer激活SWRevealViewController平移手势

[英]UIScreenEdgePanGestureRecognizer to activate SWRevealViewController pan gesture

我正在使用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;

要使用UIScreenEdgePanGestureRecognizer替换UIPanGestureRecognizer,请执行以下操作:

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

    _panGestureRecognizer.edges = UIRectEdgeLeft;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM