ritardata Nella mia app ho aggiunto le nuove Recognizers gesto che sono disponibili nel 3.2 SDK. Tutto sembra funzionare correttamente e il tempo di risposta sullo schermo è stato molto veloce. Ma per qualche motivo quando aggiungo lo requireGestureRecognizerToFail
ad alcuni dei miei gesti, c'è un ritardo molto visibile quando il gesto viene attivato. Di seguito è riportato uno snippet del codice che utilizzo per creare i Gesture Recognizers. Qualcuno sa perché c'è un ritardo e come posso risolvere il problema? Sto utilizzando requireGestureRecognizerToFail
per impedire che il gesto SingleTap
venga attivato quando l'utente esegue un DoubleTap
.iPad Gesture Recognizer - Risposta
- (void)createGestureRecognizers {
//Single Finger Double-Tap
UITapGestureRecognizer *singleFingerDTap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSingleDoubleTap:)];
singleFingerDTap.numberOfTapsRequired = 2;
[super addGestureRecognizer:singleFingerDTap];
//Single Finger Tap
UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSingleTap:)];
singleFingerTap.numberOfTapsRequired = 1;
[singleFingerTap requireGestureRecognizerToFail:singleFingerDTap];
[self addGestureRecognizer:singleFingerTap];
//Two Finger Pan
UIPanGestureRecognizer *panGesture2 = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:@selector(handlePanGesture2:)];
panGesture2.maximumNumberOfTouches = 2;
[super addGestureRecognizer:panGesture2];
//Single Finger Pan
UIPanGestureRecognizer *panGesture1 = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:@selector(handlePanGesture1:)];
panGesture1.maximumNumberOfTouches = 1;
[panGesture1 requireGestureRecognizerToFail:panGesture2];
[super addGestureRecognizer:panGesture1];
[singleFingerDTap release];
[singleFingerTap release];
[panGesture1 release];
[panGesture2 release];
}
Non è un comportamento previsto? Se gli chiedi di ritardare la sua azione fino a quando un altro gesto fallisce, allora non può sparare finché non è finita. E due tocchi hanno un intervallo di tempo tra di loro (tocca! = Tocca), quindi è necessario passare questo intervallo di tempo. – Eiko
Grazie, ha perfettamente senso! – Maddoxx