我已经实现了UIView
UIPanGesture
,当用户拖动UIView
一半时会执行某些操作。截至目前,它的工作正常。现在,在同一个UIView
内,我想实现一个UISwipeGesture
,所以当用户刷新时,会调用其他一些方法。我一直在阅读有关UIGestureRecognizerDelegate
方法的内容,我认为我需要使用gestureRecognizer:shouldRequireFailureOfGestureRecognizer:
,但我不确定。
我在viewDidLoad中实现了以下内容,并收到错误消息“无效参数。无法识别的选择器已发送到实例”
UIPanGestureRecognizer * panRec = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
panRec.delegate = self;
[panedView addGestureRecognizer:panRec];
UISwipeGestureRecognizer * swipeRec = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
swipeRec.direction = UISwipeGestureRecognizerDirectionUp;
swipeRec.delegate=self;
[panedView addGestureRecognizer:swipeRec];
[self gestureRecognizer:swipeRec shouldRequireFailureOfGestureRecognizer: panRec];
答案 0 :(得分:0)
gestureRecognizer:shouldRequireFailureOfGestureRecognizer:
是UIGestureRecognizer的委托。意思是,您将实现该方法,并且当手势发生时,将自动调用此方法。要启用调用此方法的手势识别器,您需要将手势识别器委托设置为self,这可以在viewDidLoad中完成。