IOS:UIgestureRecognitor和触摸屏

IOS:UIgestureRecognitor和触摸屏,ios,xcode,uigesturerecognizer,Ios,Xcode,Uigesturerecognizer,在我看来,我使用三种方法(touchBegind、touchmoved和touchended),因为我在视图中着色; 我的问题是,我想在此视图中添加一个带有2个点击的UITapGestureRecognitor; 可能吗?或者不允许这个手势?是的,这是可能的 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [super touchesBegan:touches withEvent:event]; UITouch

在我看来,我使用三种方法(touchBegind、touchmoved和touchended),因为我在视图中着色; 我的问题是,我想在此视图中添加一个带有2个点击的UITapGestureRecognitor; 可能吗?或者不允许这个手势?

是的,这是可能的

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];

UITouch *touch = [touches anyObject];
if([touch tapCount] == 2){
     NSLog("2 taps");
}
}

这可能会对你有所帮助。只是别忘了在重写方法中调用
[super…]
。可能还需要一些额外的调整,这取决于您想要实现的确切行为。我将编写一个代码,但无法测试它,因为我现在在win计算机上。Sachin的老派(手势识别器)可能也能工作。你对这个检查:但这个数字是一个序列吗?(轻拍)还是两个手指在一起?轻拍,你想要两个手指在一起吗?
    UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected)];
    doubleTap.numberOfTapsRequired = 2;
    [self.view addGestureRecognizer:doubleTap];
    [doubleTap release];


-(void)tapDetected{
    NSLog(@"Double Tap");

}