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

iOS Build a Photo Browser iPhone App Gestures Creating a Detail View Controller

Now a single tap opens each picture, I can't double-tap to 'Like' a picture.

Hi all,

I've been working through the Photo Bomber application with iOS and Instagram.

We added gesture functionality to spot a double-tap and to like the photo this was done on. Subsequently, we added a single tap to enlarge the pic into its own view, full-size.

In my app, the single tap overrides the double-tap so I can no longer 'Like' a pic.

Did I miss something?



1 Answer

Adam Nieto
Adam Nieto
1,561 Points

In the THPhotoCell.m file you'll see the code below which indicates the like gesture was updated to be a long press instead of a double tap. Don't remember if this was covered in the course or not.

- (void)like:(id)sender {
    UILongPressGestureRecognizer *longPress = (UILongPressGestureRecognizer *)sender;
    if ( longPress.state == UIGestureRecognizerStateEnded) {
        NSURLSession *session = [NSURLSession sharedSession];
        NSString *accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:@"accessToken"];
        NSString *urlString = [[NSString alloc] initWithFormat:@"https://api.instagram.com/v1/media/%@/likes?access_token=%@", self.photo[@"id"], accessToken];
        NSURL *url = [[NSURL alloc] initWithString:urlString];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        request.HTTPMethod = @"POST";
        NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            dispatch_async(dispatch_get_main_queue(), ^{
                [self showLikeCompletion];
        [task resume];