IOS:UIgestureRecognizer和touchesBegan

时间:2012-06-12 10:28:17

标签: ios xcode uigesturerecognizer

在我看来,我使用了三种方法(touchbegan,touchmoved和touchended),因为我在视图中着色; 我的问题是我想在这个视图中添加一个带2个水龙头的UITapGestureRecognizer; 可能吗?或者touchbegan不允许这种姿势?

2 个答案:

答案 0 :(得分:1)

雅可能

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

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

愿这对你有帮助

答案 1 :(得分:-1)

    UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected)];
    doubleTap.numberOfTapsRequired = 2;
    [self.view addGestureRecognizer:doubleTap];
    [doubleTap release];


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

}