我想在視圖中一起使用水龍頭手勢和長按手勢。但我的問題是,我無法在水龍頭上運行輕按手勢操作。但長按手勢工作正常。水龍頭手勢+長按手勢都沒有在一起工作
這裏是代碼片段。
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