Ios 检测用户何时停止触摸按钮
我有一个UIButton,上面有一个UIPanGesture。当用户按下UIButton时,我调用事件Ios 检测用户何时停止触摸按钮,ios,objective-c,uibutton,Ios,Objective C,Uibutton,我有一个UIButton,上面有一个UIPanGesture。当用户按下UIButton时,我调用事件Touch down。我还想知道用户在屏幕上拖动按钮后,何时将手指从按钮上抬起。我尝试过使用代理,如触动内部或触动拖动退出,但在拖动UIButton后,这些代理似乎不起作用…仅当平移手势识别器启动时才会触发。如果用户仅仅点击按钮,它将不会触发 -(void)setupGesture { UIPanGestureRecognizer *pan = [[UIPanGestureRecogni
Touch down
。我还想知道用户在屏幕上拖动按钮后,何时将手指从按钮上抬起。我尝试过使用代理,如触动内部
或触动拖动退出
,但在拖动UIButton后,这些代理似乎不起作用…仅当平移手势识别器启动时才会触发。如果用户仅仅点击按钮,它将不会触发
-(void)setupGesture
{
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
[self.yourButton addGestureRecognizer:pan];
}
-(IBAction)handlePan:(UIPanGestureRecognizer *)sender
{
switch (sender.state) {
case UIGestureRecognizerStateEnded:
//Should fire when the user lifts finger
break;
default:
break;
}
}
尝试UIControlEventTouchCancel@user3705414不幸的是,每当用户开始拖动时,它调用UIControlEventTouchCancel,我希望在抬起手指时调用它。