检测触摸拖动外部的结束

时间:2014-07-16 15:00:23

标签: ios objective-c xcode touch

我在一个按钮上有一个Touch Drag Outside事件,我想在用户停止拖动并再次抬起屏幕的手指时检测并运行一个方法。我找不到与按钮中匹配的事件,而touchesEnded也无效。 怎么办?

2 个答案:

答案 0 :(得分:0)

您应该使用touchesCancelled:withEvent:

答案 1 :(得分:0)

You can use "PangestureRecognizer" in this case and can determine the states of gestures

if (gestureRecognizer.state == UIGestureRecognizerStateBegan) 
{

//do something

}

else if (gestureRecognizer.state == UIGestureRecognizerStateChanged) 
{

//do something

}
else if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
{

//do something

}
相关问题