我在我的应用中添加了 swrevealcontroller 。点击表格中的项目,它会打开一个新的视图控制器。我在该视图控制器中添加了 pageControl 。首先 pagecontrol 的时间平移手势有效但下次平移手势不适用于页面控制。请告诉我如何避免平移手势的冲突。
- (void)_handleRevealGesture:(UIPanGestureRecognizer *)recognizer
{
NSLog(@"handle pan gesture");
CGPoint velocity = [recognizer velocityInView:self.view]; if(velocity.x > 0)
{
NSLog(@"gesture went right");
}
else
{
NSLog(@"gesture went left");
if(self.isReaveled)
{
switch ( recognizer.state )
{
case UIGestureRecognizerStateBegan:
[self _handleRevealGestureStateBeganWithRecognizer:recognizer];
break;
case UIGestureRecognizerStateChanged:
[self _handleRevealGestureStateChangedWithRecognizer:recognizer];
break;
case UIGestureRecognizerStateEnded:
[self _handleRevealGestureStateEndedWithRecognizer:recognizer];
break;
case UIGestureRecognizerStateCancelled:
//case UIGestureRecognizerStateFailed:
[self _handleRevealGestureStateCancelledWithRecognizer:recognizer];
break;
default:
break;
}
}
}
}
我修改了上面的代码是为了工作,但是它不起作用。
答案 0 :(得分:0)
您首先在使用pagecontroller的视图控制器中设置了swrevealcontroller的pan手势的委托。为此,还要添加gesturerecogniser的委托。
实现GestureRecongnizer的这个委托方法。
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if (otherGestureRecognizer.delegate == self)
return NO;
if ([[otherGestureRecognizer.view class] isSubclassOfClass:[UIPageViewController class]]) {
NSLog(@"Allow1 %@", [otherGestureRecognizer description]);
return YES;
}
NSLog(@"Deny %@", [otherGestureRecognizer description]);
return NO;
}
希望它会帮助你。