2010-04-06 3 views

답변

9

보기의 touchesBegan:에서 "지연 탭"핸들을 약간 지연시켜 호출 할 수 있습니다. 충분한 시간이 경과 한 경우 뷰의 touchesEnded:에서

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

당신은 전화를 취소 할 수 있습니다

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

thanksssssssss을! 네가 내 목숨을 구했어! (+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"); 

    } 

} 
관련 문제