Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to hide "-" (Delete) button while editing UITableView

On my iphone app, I have a UITableView in edit mode, where user is allowed only to reorder the rows no delete permission is given.

So is there any way where I can hide "-" red button from TableView. Please let me know.

Thanks

like image 639
iPhoneDev Avatar asked Jun 11 '10 07:06

iPhoneDev


People also ask

How do I hide a Tableview section?

You can't "hide" a section as such, but you can "delete" it from the table view using the deleteSections:withRowAnimation: method. This will remove it from the view, with an optional animation, without affecting your backing data. (You should, however, update the data anyway so that the section doesn't reappear.)

How do I delete a cell in Uitableview?

So, to remove a cell from a table view you first remove it from your data source, then you call deleteRows(at:) on your table view, providing it with an array of index paths that should be zapped. You can create index paths yourself, you just need a section and row number.

How do you delete a row in Tableview?

When a user slides horizontally across a row the editing style of the Tabel View Cell is set to delete. When the delete button is pressed, the item is deleted in the array and also the row is deleted in the Table View. Build and run the project and swipe-to-delete a row from the Table View.


1 Answers

Here is my complete solution, without indentation (0left align) of the cell!

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {     return YES; }  - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{     return UITableViewCellEditingStyleNone;  }  - (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {     return NO; }   - (BOOL)tableView:(UITableView *)tableview canMoveRowAtIndexPath:(NSIndexPath *)indexPath {     return YES; } 
like image 79
Stefan von Chossy Avatar answered Oct 15 '22 18:10

Stefan von Chossy