【问题标题】:Detect end of Touch Drag Outside检测外部触摸拖动结束
【发布时间】:2014-07-16 15:00:23
【问题描述】:

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

【问题讨论】:

  • 这个[button addTarget:self action:@selector(go) forControlEvents:UIControlEventTouchUpOutside];?

标签: ios objective-c xcode touch


【解决方案1】:

你应该选择touchesCancelled:withEvent:

【讨论】:

    【解决方案2】:
    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
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多