[英]iPhone UIView touchesMoved: withEvent: does not get called on UIView with gesture recognizers
[英]touchesEnd does not get called bit touchesBegin and touchesMoved does get called
我試圖在ios中拖延。 如果拖動移動距離很短,我會將拖動計為點擊事件,方法是將開始x,y(來自touchesBegan)與touchesEnd中的x,y進行比較。 似乎touchesEnd永遠不會被調用。 我給了一個斷點來驗證它並且斷點從未消失。
code:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSUInteger touchCount = [touches count];
NSUInteger tapCount = [[touches anyObject] tapCount];
[ self UpdateDrag];
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSUInteger touchCount = [touches count];
NSUInteger tapCount = [[touches anyObject] tapCount];
}
- (void) touchesEnd:(NSSet *)touches withEvent:(UIEvent *)event {
// this methes never gets called
NSUInteger touchCount = [touches count];
NSUInteger tapCount = [[touches anyObject] tapCount];
if (mDisplay==nil)
{
mDisplay = [[cDisplayYesOrNo_iPhone alloc]
initWithNibName:@"cDisplayYesOrNo_iPhone"
bundle:[NSBundle mainBundle]];
}
[ mDisplay SetUp];
[self presentModalViewController: mDisplay animated:NO];
}
是- (void)touchesEnded:
not - (void)touchesEnd:
你需要編輯touchesEnd
到touchesEnded
。
此外,對於完整性,你需要考慮你是否還需要應對touchesCancelled
這就是所謂的替代touchesEnded
在某些情況下。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.