Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Andrés Leal
Andrés Leal
9,563 Points

Who to add a double tap like? "Instagram Like" in swift

I want to add a like button, when you double tap the view it shows the like, but I don't know how to do that, any ideas?

2 Answers

Carmine Sarno
Carmine Sarno
19,660 Points


I'd suggest investigating using UITapGestureRecognizer, which is a subclass of UIGestureRecognizer. I haven't made a double-tap interface like you're describing, but I think that could be done by setting the numberOfTapsRequired property to 2.

Pasan covers using this class in the "Playlist Browser with Swift / Obj-C" course, so I'd check that out for implementation instructions. The specific video is called "Adding Touch Capabilities" in the "Building the Master and Detail Views" section.

Swift video

Obj-C video

Jhoan Arango
Jhoan Arango
14,575 Points

When creating an app, in Xcode there are some gestures recognizers that can do that. :)