我想在视图中一起使用水龙头手势和长按手势。但我的问题是,我无法在水龙头上运行轻按手势操作。但长按手势工作正常。水龙头手势+长按手势都没有在一起工作
这里是代码片段。
UILongPressGestureRecognizer *longPressGesture=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(ontappLongPressGesture:)];
longPressGesture.minimumPressDuration=0.6;
longPressGesture.delegate=self;
[cell.view addGestureRecognizer:longPressGesture];
UITapGestureRecognizer *gesture=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cellSelected:)];
//[gesture requireGestureRecognizerToFail:longPressGesture]; //I have tried with this line also but not working
gesture.delegate=self;
[cell.view addGestureRecognizer:gesture];
而且我已委托方法也
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
这种方法获取调用长按
- (void)ontappLongPressGesture:(id)sender{
//Long press code here
}
但是这种方法没有得到所谓的自来水
-(void)cellSelected:(id)sender {
//Single tap code here
}
我测试了这一点,并删除了委托,它的工作。 – Arbitur
尝试删除代表。你告诉他们可以同时开火的姿势。不是这种情况。您只需轻按或长按即可。不是都。 – Fogmeister