For customization reasons I'm building my own slider control, which is build using several UIImageViews and a UIButton if needed. I've got the panning working using a UIPanGestureRecognizer, which is working fine. I'm trying to hook an event in that will handle the code for UIControlEventTouchUpInside, but I can't get it to fire after the Pan event fires. I've got this working with both a UITapGestureRecognizer and using the built in event for the UIButton, but it only fires if it's the only gesture. I need to know when the user is no longer dragging the slider left and right, but it can only happen after the user lifts his/her/its finger from the screen (I can't use timers to see when the movement stopped because the user may still be deciding which direction to go after starting the Pan).

The short version: How do I know when a user stops panning a control and lifts his finger off the screen?

有帮助吗?

解决方案

Let's say you initialize your recognizer like this:

UIPanGestureRecognizer *grPan=[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panning:)];

you can do this:

-(void)panning:(UIPanGestureRecognizer *)senderGestureRecognizer {
    if(senderGestureRecognizer.state==UIGestureRecognizerStateEnded)
    {
        //User stopped panning (lifted finger)
    }
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top