Question

I've implemented that when the my UIButton is highlighted and my UISwipeGestureRecognizer recognizes the gesture it will begin an animation. The problem is I want to end the animation when touchesEnded gets called after selecting the UIButton and making a gesture. But touchesEnded never gets called if I tap a UIButton in the process.

The rest of the time it works, but its useless to me if I can't use it during my animation. Here is what I did:

-(IBAction) swipeDown:(UISwipeGestureRecognizer *)recognizer
{
     if(onebutton.highlighted)
     {
          //Animate
     }
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    for(UITouch *touch in touches)
    { 
        if(touch.phase == UITouchPhaseEnded)
        { 
            NSLog(@"touched");
        } 
    } 
}

Any ideas?

Was it helpful?

Solution

Instead of touchesEnded, you could add another action for your button that is triggered when it is released.

[button addTarget:self action:@selector(buttonTapEnded) forControlEvents:(UIControlEventTouchUpInside|UIControlEventTouchUpOutside)];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top