![](/img/trans.png)
[英]touchesMoved, how do I make my view catch up - and stay under the finger?
[英]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.