Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have a UITableViewCell show the delete button without the red minus

I want to implement a UITableView that when I press a button in my ViewController, I can see the delete button on the right of the cell, but not the red minus circle on the the left of the cell.

Any ideas on this?

like image 618
George Avatar asked Apr 24 '13 08:04

George


2 Answers

Just an approach:

  1. Have a delete button on a view and assign a method to it
  2. In this method, toggle a BOOL isDeleteEnabled (or whatever you name it) to TRUE
  3. Reload the UITableView and in cellForRowAtIndexPath check for that BOOL value
  4. If TRUE then load the all the UITableViewCell as custom cells with delete button on it (You need to set the selector method for deletion of a row)
  5. Delete as many cells as you want by tapping that button on the cells
  6. After deleting your choices you can again press the main button and toggle the value for isDeleteEnabled
  7. Again reload UITableView and this time in cellForRowAtIndexPath check the value of isDeleteEnabled - which will be FALSE. So, you need to load normal(or your original) UITableViewCells.

I have done the very similar thing following this approach.

Also, I haven't posted the code for it for three reasons:

  • It would be too lengthy in size
  • The code his available at my work machine (to which I am not having access right now)
  • It will ruin the joy of coding such a task. Do it yourself. You will enjot it.
like image 150
viral Avatar answered Nov 04 '22 11:11

viral


that simple if you dont want the minus sign to appear, consider implementing you own solution than default one, insert a delete button and provide an animation to it, do as you require

like image 27
Firdous Avatar answered Nov 04 '22 10:11

Firdous