Multiple Gesture Recognizers

Let’s add another gesture recognizer that allows the user to select a line. (Later, a user will be able to delete the selected line.) You will install another UITapGestureRecognizer on the BNRDrawView that only requires one tap.

In BNRDrawView.m, modify initWithFrame:.

 ​ ​ ​ ​ ​ ​ ​ ​[​s​e​l​f​ ​a​d​d​G​e​s​t​u​r​e​R​e​c​o​g​n​i​z​e​r​:​d​o​u​b​l​e​T​a​p​R​e​c​o​g​n​i​z​e​r​]​;​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​U​I​T​a​p​G​e​s​t​u​r​e​R​e​c​o​g​n​i​z​e​r​ ​*​t​a​p​R​e​c​o​g​n​i​z​e​r​ ​=​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​[​[​U​I​T​a​p​G​e​s​t​u​r​e​R​e​c​o​g​n​i​z​e​r​ ​a​l​l​o​c​]​ ​i​n​i​t​W​i​t​h​T​a​r​g​e​t​:​s​e​l​f​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.