在我的應用程序中,我添加了3.2 SDK中提供的新手勢識別器。一切似乎都正常工作,屏幕上的響應時間非常快。但由於某些原因,當我將requireGestureRecognizerToFail
添加到我的某些手勢中時,手勢觸發時會出現非常明顯的延遲。以下是我用來創建手勢識別器的代碼片段。有誰知道爲什麼有一個延遲,我怎麼能解決它?我使用requireGestureRecognizerToFail
來防止在用戶執行DoubleTap
時觸發SingleTap
手勢。iPad手勢識別器 - 延遲響應
- (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];
}
這不是預期的行爲?如果你要求它延遲其行動,直到另一個手勢失敗,那麼在此結束之前它不能發射。兩個水龍頭之間有時間跨度(水龍頭!=觸摸),所以你需要這個時間跨度。 – Eiko 2010-06-20 22:59:55
謝謝,這很有道理! – Maddoxx 2010-06-21 00:38:21