2010-04-06 4 views

Répondre

9

En vue touchesBegan: vous pouvez appeler votre poignée "long robinet" avec un certain retard.

[touchHandler performSelector:@selector(longTap:) withObject:nil afterDelay:1.5]; 

Ensuite, en vue de vous touchesEnded: pouvez annuler cet appel si pas assez de temps a passé:

[NSObject cancelPreviousPerformRequestsWithTarget:touchHandler selector:@selector(longTap:) object:nil]; 
+0

thanksssssssss! tu m'as sauvé la vie! (+1) – SpaceDog

2
//Add gesture to a method where the view is being created. In this example long tap is added to tile (a subclass of UIView): 

    // Add long tap for the main tiles 
    UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTap:)]; 
    [tile addGestureRecognizer:longPressGesture]; 
    [longPressGesture release]; 

-(void) longTap:(UILongPressGestureRecognizer *)gestureRecognizer{ 
    NSLog(@"gestureRecognizer= %@",gestureRecognizer); 
    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) { 
     NSLog(@"longTap began"); 

    } 

}