Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 检测用户何时停止触摸按钮_Ios_Objective C_Uibutton - Fatal编程技术网

Ios 检测用户何时停止触摸按钮

Ios 检测用户何时停止触摸按钮,ios,objective-c,uibutton,Ios,Objective C,Uibutton,我有一个UIButton,上面有一个UIPanGesture。当用户按下UIButton时,我调用事件Touch down。我还想知道用户在屏幕上拖动按钮后,何时将手指从按钮上抬起。我尝试过使用代理,如触动内部或触动拖动退出,但在拖动UIButton后,这些代理似乎不起作用…仅当平移手势识别器启动时才会触发。如果用户仅仅点击按钮,它将不会触发 -(void)setupGesture { UIPanGestureRecognizer *pan = [[UIPanGestureRecogni

我有一个UIButton,上面有一个UIPanGesture。当用户按下UIButton时,我调用事件
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,我希望在抬起手指时调用它。