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