With my current table view controller, I’d like to implement a touch and hold feature very similar to how the click-wheel iPod’s On-The-Go queueing feature used to work.
I’ve been reading a few posts and have seen suggestions for using UILongPressGestureRecognizer. Whilst I could do that, it does bring up a couple more questions for me:
- If a long press is detected, how can I prevent the
didSelectRowAtIndexPathmethod from being called (Or do I
completely avoid using it and implement a Tap gesture recogniser in
my UITableViewCell subclass?) - How would I go about animating the cell once a long-press has been
detected similar to the iPod style (where the highlighted cell
flashes/opacity of highlight goes up and down a few times).
Would appreciate some guidance.
If you use the long press recognizer, and it fires, didSelectRowAtIndexPath will not fire.
You can detect the state of the gesture recognizer and animate your cell after the ‘start’ state is detected, and end the animation when the ‘end’ state is detected.
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) …
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) …