O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting Taps with UITapGestureRecognizer

The first UIGestureRecognizer subclass you will use is UITapGestureRecognizer. When the user taps a line in TouchTracker, you will present a menu that allows them to delete it. Open TouchTracker.xcodeproj from Chapter 19.

In the first part of this section, we are going to recognize a tap, determine which line is close to where the tap occurred, store a reference to that line, and change that line’s color to green so that the user knows it has been selected.

In TouchDrawView.m, edit the initWithFrame: method to create an instance of UITapGestureRecognizer and attach it to the TouchDrawView being initialized.

-​ ​(​i​d​)​i​n​i​t​W​i​t​h​F​r​a​m​e​:​(​C​G​R​e​c​t​)​r​ {​ ​ ​ ​ ​s​e​l​f​ ​=​ ​[​s​u​p​e​r​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required