繁体   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