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​ ...

Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.