iOS 单击手势和双击手势冲突解决

UITapGestureRecognizer *atap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(atapAction)];
    [self.view addGestureRecognizer:atap];
    
    UITapGestureRecognizer *doubleClick = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleClickAction)];
    doubleClick.numberOfTapsRequired = 2;
    [self.view addGestureRecognizer:doubleClick];
    
    //当系统检测不到双击手势时执行再识别单击手势
    [atap requireGestureRecognizerToFail:doubleClick];

你可能感兴趣的:(UIGesture)