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

Genady Novak
Genady Novak
5,164 Points

Table View Cell

I want to add a slide to my table cell. Is it possible to make the cell to move left and that return by itself? I want it to look like a refresh gesture in Facebook app but for a single cell.

1 Answer

Stone Preston
Stone Preston
42,016 Points

in cellForRowAtIndex path you can add a swipe gesture:

UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc]
                                             initWithTarget:self action:@selector(swipeOccurredIn:)];
[gesture setDirection:UISwipeGestureRecognizerDirectionRight];
[cell addGestureRecognizer:gesture];

then implement the method you specified in the selector to handle the swipe:

- (void)swipeOccurredIn:(UISwipeGestureRecognizer *)recognizer {    

        NSLog(@"%d = %d",recognizer.direction,recognizer.state);
}

Im not sure about animating the cell on the swipe though. thats going to be the hard part

here is something that might work for you. its a custom tableView cell class for swiping

Genady Novak
Genady Novak
5,164 Points

Thank you it was very helpful !!