簡體   English   中英

touchesEnd沒有被稱為bit touchesBegin和touchesMoved被調用

[英]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];


}

你需要編輯touchesEndtouchesEnded

此外,對於完整性,你需要考慮你是否還需要應對touchesCancelled這就是所謂的替代touchesEnded在某些情況下。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM