kreeger / BDKCollectionIndexView

Gives a UICollectionView the sectionIndexTitles scrub bar that a UITableView gets for almost free.
MIT License
158 stars 29 forks source link

Handle long press gesture with gesture recognizer #5

Closed rinatkhanov closed 9 years ago

rinatkhanov commented 9 years ago

Original implementation of handling long press gesture with touchesBegan wasn't very reliable in my experience (though it works fine in the example project). Specifically, touchesEnded method wasn't called after long press in some cases and index view seemed "stuck" with enabled highlighted background (I've tried adding touchesCanceled method too, but I still wasn't satisfied with the result β€” the background would blink the moment "long press" turns into pan gesture).

The solution for me was to replace touchesBegan / touchesEnded methods with simple UILongPressGestureRecognizer and one delegate method. Everything else works the same, but background always un-highlights when you lift the finger and gesture handling is more concise now.

P.S. Thanks for the project. πŸ‘

kreeger commented 9 years ago

Thanks, @rinatkhanov! I'll review this this weekend and see about merging this in.

kreeger commented 9 years ago

@rinatkhanov better late than never β€”Β thanks for this!

kreeger commented 9 years ago

This is now available in v2.0.0.

https://github.com/kreeger/BDKCollectionIndexView/releases/tag/v2.0.0

rinatkhanov commented 9 years ago

OK, cool πŸ‘