Swipe gestures on UITableView

User interactions on table cells don’t have to be necessarily restricted to simply scroll and tap them. However, with some additional code and the support of gesture recognizers introduced in iOS 3.2 you can give your users the possibility to swipe on your table view cells for exciting additional actions. A common task for that would be to implement a swipe gesture for removing a single item within your table view (seen on several task management and todo apps) or simply changing the state of an item.

All you need is some pretty forward code like the following, which basically creates two gesture recognizers to handle left and right swipes on your table. As you can see we add these gesture recognizers directly to a UITableView  rather than to single UITableViewCells .

The called methods of the gesture recognizers look like as stated below. From the gesture recognizer you’ll get the point of the start of the swipe gesture and with the indexPathForRowAtPoint:  method you can get the correct index path for the UITableViewCell  the swipe was performed on. From this point on it is up to you to perform more functionality to your table view cell.

4 responses to “Swipe gestures on UITableView”

  1. Carlos Maria Caraccia Avatar
    Carlos Maria Caraccia

    Hi! Great Tutorial!! It works really great! Nevertheless I am having a slight problem.
    When I move my table view up or dow, the checkmark disappears, I guess it is because of the reusable cell, thats being instantiated again and the checkmark is not added there.
    Have you got any idea of how to solve this? My idea is to add id to a cell I create.

  2. […] Handle Swipe Gestures on UITableview: How to associate a Swipe with a particular table row […]

  3. Bhargav Bhatti Avatar
    Bhargav Bhatti

    how to uitableviewcell swipe left and right to move next uitableviewcell

  4. Bhargav Bhatti Avatar
    Bhargav Bhatti

    plz reply me..

Leave a Reply

Your email address will not be published. Required fields are marked *