gpt4 book ai didi

ios - 当我的手指离开 subview 时,我的程序如何忽略 touchesMoved?

转载 作者:行者123 更新时间:2023-11-28 22:33:25 25 4
gpt4 key购买 nike

我目前有一个带有 View Controller 和 subview 的程序。 subview 中包含所有触摸逻辑。当我将手指滑出 subview 时,touchesMoved 方法不会停止处理我的触摸信息。我知道 touchesMoved 方法在我将手指离开屏幕之前不会结束,但是必须有一种方法可以让我的程序在我的手指离开 subview 后忽略触摸。任何人都知道可以做到这一点的任何此类方法吗?

最佳答案

- (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
}
}

关于ios - 当我的手指离开 subview 时,我的程序如何忽略 touchesMoved?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16803612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com