当我从xcode中的区域拖动时,如何将UIButton启用为触摸?

时间:2021-07-29 21:16:40

I am trying to make a UIButton be able to be enabled if I drag my finger from the region outside the button. It only works right now if I press the button like normal. I have tried using all of the events, but it doesn't look like it even will respond to any of the drag events. I have searched everywhere, but I cannot find an answer. Thanks!

如果我从按钮外面的区域拖动手指,我试图使UIButton能够启用。如果我像平常一样按下按钮,它现在才有效。我已经尝试过使用所有事件,但看起来它甚至不会响应任何拖动事件。我到处搜索,但我找不到答案。谢谢!

1 个解决方案

#1


1  

You should need to use a selector to dragEnter event for a UIButton.

您应该使用选择器来为UIButton执行dragEnter事件。

[your addTarget:self action:@selector(buttonDragged:)   
      forControlEvents:UIControlEventTouchDragEnter];

and implement the buttonDragged: method

并实现buttonDragged:方法

-(void)buttonDragged:(UIButton*) sender{
  //Your logic here
}

#1


1  

You should need to use a selector to dragEnter event for a UIButton.

您应该使用选择器来为UIButton执行dragEnter事件。

[your addTarget:self action:@selector(buttonDragged:)   
      forControlEvents:UIControlEventTouchDragEnter];

and implement the buttonDragged: method

并实现buttonDragged:方法

-(void)buttonDragged:(UIButton*) sender{
  //Your logic here
}