Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS reordering table view rows without delete button

I've to reordering UITableView rows without show the default red minus button because I need to show my custom image and I don't need to remove cell from UITableView. Is there a way for reordering rows even if table is not in editing mode ?

enter image description here

like image 755
Fry Avatar asked Apr 17 '15 18:04

Fry


People also ask

What happens when a user taps a row in a Tableview?

When the user taps a row, the table view calls the delegate method tableView (_:didSelectRowAt:). At this point, your app performs the action, such as displaying the details of the selected hiking trail:

How do I clear the selection in a uitableviewcontroller?

If you’re using a UITableViewController to display a table view, you get the behavior by setting the clearsSelectionOnViewWillAppear property to true. Otherwise, you can clear the selection in your view controller’s viewWillAppear (_:) method:

How to get the number of rows in a table view?

There is only one section in the Table View so 1 needs to be returned in the numberOfSections (in:) method. The number of rows is equal to the number of items in the cars array so the count property of the array class is used.

What is the default setting of Tableview didselectrowat?

The default is false. Determines whether user can select a row while the table view is in editing mode. The default is false. Determines whether users can select a more than one row while in editing mode. The default is false. When the user taps a row, the table view calls the delegate method tableView (_:didSelectRowAt:).


2 Answers

You will need to add this delegate method to not show the delete button

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
return UITableViewCellEditingStyleNone;
}
like image 122
rmp Avatar answered Oct 11 '22 04:10

rmp


I think, you should check out the followings: https://www.cocoacontrols.com/controls/reordertableviewcontroller https://www.cocoacontrols.com/controls/reorderabletableview

like image 1
Shoaib Avatar answered Oct 11 '22 04:10

Shoaib