Editing Mode in UITableView

So I implemented

- (BOOL)tableView:(UITableView *)tableView
canEditRowAtIndexPath:(NSIndexPath *)indexPath

and

- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath

but how can I call something to switch the table view to edit mode? like iphone messages, when you click β€œEdit”, delete icons appear. it may seem very simple, but I don’t understand what it is, and its a little urgent, any key will be appreciated, thanks.

+3
source share
2 answers
[tableView setEditing:YES animated:YES];
+5
source

You can also use the navigation controller and load a table view into it. Then just assign the edit button to the left navigation bar and it will switch the editing for you.

// in the table viewDidLoad

self.navigationItem.rightBarButtonItem = self.editButtonItem;
+2
source

Source: https://habr.com/ru/post/1784236/


All Articles