jvpython
jvpython

Reputation: 11

Delete cells in table view Iphone with edit button

I have a table view with different cells and basically I would like an edit button which would then make those red circle appear in each cell and be able to delete them. I already know how to make the "Edit" button appear and also I have overridden the commitEditingStyle method for the table view so I would like to know how to link the button to the action which trigers the red circle and how to make them appear and finally how to actually delete the cells thankyou :)

Upvotes: 1

Views: 1445

Answers (2)

Justin Spahr-Summers
Justin Spahr-Summers

Reputation: 16973

The editing style on your table view cells should be set to UITableViewCellEditingStyleDelete, and then you just need to make sure to call setEditing:animated: on your table view. UITableViewController can help provide a lot of this functionality pre-baked.

Upvotes: 4

Ertebolle
Ertebolle

Reputation: 2342

That's actually done through an undocumented API (though I'm not quite sure why) - using it would probably get your app rejected.

However, lots of apps simulate this functionality with their own code - you'd basically define a custom UITableViewCell subclass which changed its background color / toggled that extra red circle image when tapped, keep track of which cells had been tapped, and finally delete them all by calling deleteRowsAtIndexPaths: on the table with the collected list of rows.

Upvotes: -1

Related Questions