Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Build a Photo Browser iPhone App Gestures Triple-Tap Gesture Recognizer.

Declare a variable and alloc/init it as a gesture recognizer. Then set it to be a triple-tap gesture recognizer.

Sam Soffes

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self];
tap.numberOfTapsRequired = 3;
[self addGestureRecognizer:tap];

the code isn't working. I've checked for spelling issues and syntax, but I don't see any errors.

7 Answers

Amit Bijlani

I must be missing something. This is the last thing I need to complete my iOS Track. What could I be doing wrong?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Your answer above is right but the code challenge is wrong because it is expecting the following:

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
tap.numberOfTapsRequired = 3;

We will have it fixed. Meanwhile, you can use the above code to pass it. Sorry about that!

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(workAlready)];
tap.numberOfTapsRequired = 3;
[self addGestureRecognizer:tap];

I tried that too..

Sam Soffes
STAFF
Sam Soffes
Treehouse Guest Teacher

Can you be more specific than "it's not working"? Also I'm assuming self here is a view and not a view controller.

The code challenge states: "Declare a variable and alloc/init it as a gesture recognizer. Then set it to be a triple-tap gesture recognizer."

I've tried:

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(workAlready)];
tap.numberOfTapsRequired = 3;
[self.view addGestureRecognizer:tap];

also:

[self addGestureRecognizer:tap];

Maybe I'm reading the challenge wrong. Sorry if this isn't very descriptive; I don't know how to explain further.

The challenge: Declare...

What a relief!