我有两个UITapGestureRecognizer:使用两个不同的动作初始化singleTap和doubleTap.
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; [singleTap requireGestureRecognizerToFail:doubleTap]; [doubleTap setNumberOfTapsrequired:2]; [imageView addGestureRecognizer:doubleTap]; [imageView addGestureRecognizer:singleTap];
当我在模拟器中运行我的应用程序时,单击可以正确响应但不是双击!当我点击双击时,我发现iOS剂量识别双击,因为没有调用单击的动作(由于[singleTap requireGestureRecognizerToFail:doubleTap];),但我不明白为什么不这样做动作handleDoubleTap.