Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

caldwelljason

macrumors member
Original poster
Jul 9, 2008
44
2
OK. Bonehead question of the day:

I have added a UITableView to a view. I would like to have the "swipe to delete" behavior. Everything I read from Apple indicates it's "just there" on a UITableView. But no so much for me... :(

I am handling the editingStyleForRowAtIndexPath method and returning UITableViewCellEditingStyleDelete, but that never gets called. My other delegate methods do. I copied the signature directly from the documentation, so I believe it to be correct.

I also implemented the willBeginEditingRowAtIndexPath and didEndEditingRowAtIndexPath methods, which are (obviously) also not called.

I can set the whole table to edit mode and it works fine. But then I have the delete icons all the time. Don't want it. I also don't necessarily want to go with a button to enter and leave "Edit" mode, if I can avoid it.

Any help? Is there something I have to do to the list to get it to respond to the swipe?
 

caldwelljason

macrumors member
Original poster
Jul 9, 2008
44
2
Bonehead answer

You have to implement commitEditingStyle to get that behavior.

I wish that was documented somewhere. :rolleyes:

I decided to just move on and get the data implementation working. As soon as I added that method, my swipe action worked...:eek:

Anyway, there it is, documented so that I will find it next time I search for it...:p
 

elronaldo

macrumors newbie
Sep 22, 2008
23
0
When using this Swipe to Delete mode is it possible to detect this specific edit mode? For example when you are in swipe-delete view the left side of the cell does not need to be adjusted, as the delete circle is not shown.

Any ideas?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Come on guys, all this stuff is documented in the Table View programming guide:

The table view sends the tableView:commitEditingStyle:forRowAtIndexPath: message to the data source. Although this protocol method is marked as optional, the data source must implement it if it wants to insert or delete a row.

When the user swipes a row to delete it, the table view sends setEditing:animated: to itself and enters editing mode. In this “swipe to delete” mode, the table view does not display the editing and reordering controls. Because this is a user-driven event, it also brackets the messages to the delegate inside of two other messages:

You can do a full-text search of the documentation by the following method:

Enter the text you want to search for, say 'swipe' in the search box at the top of the documentation window. Select 'Apple iPhone OS 2.1' in the Doc Sets Pane. Choose 'Full-Text' in the selection bar at the top left. Then search.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.