簡體   English   中英

當我的手指離開子視圖時,我的程序如何忽略touchesMoved?

[英]How can my program ignore touchesMoved when my finger leaves the subview?

我目前有一個帶有viewcontroller和子視圖的程序。 子視圖中包含所有觸摸邏輯。 當我將手指滑到子視圖之外時,touchesMoved方法不會停止處理我的觸摸信息。 我知道touchesMoved方法不會結束,直到我將手指從屏幕上移開,但是必須有一種方法讓我的程序在手指離開子視圖后忽略觸摸。 有誰知道任何這樣的方法可以做到這一點?

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    CGPoint location = [[touches anyObject] locationInView:yourSubview];
    if (CGRectContainsPoint(yourSubview.frame, location))
    {
        //process touch
    }
    else
    {
        //touch is outside of the subview
    }
}

暫無
暫無

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

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