我UIView
在屏幕的某个部分有一个。这个 UIView 有平移手势识别器。这个 UIView (mainVw) 有一个UITextView
完全覆盖 UIView。此 UITextview 具有滑动手势(向左和书写)。
我的问题是当我向左或向右滑动时, UIView 也开始拖动。我想要的是,当我拖动 UIView 时它应该拖动,当我滑动 UITextView 时应该向左滑动写入但不拖动。
这是我用来更好理解的代码:
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[panGesture setMinimumNumberOfTouches:1];
panGesture.delegate =(id)self;
[self.mainVw addGestureRecognizer:panGesture];
//[self.mainVw.layer setValue:[NSValue valueWithCGPoint:vwCaptionBg.center] forKey:@"originalCenter"];
UISwipeGestureRecognizer *rightRecognizer;
rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanTouch:)];
[rightRecognizer setDirection: UISwipeGestureRecognizerDirectionRight];
rightRecognizer.delegate=(id)self;
[self.txtVw addGestureRecognizer:rightRecognizer];
UISwipeGestureRecognizer *vwLeftRecognizer;
vwLeftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanTouch:)];
[vwLeftRecognizer setDirection: UISwipeGestureRecognizerDirectionLeft];
vwLeftRecognizer.delegate=(id)self;
[self.txtVw addGestureRecognizer:vwLeftRecognizer];