Editing function in UITableView created with UIViewController

I created the table using the UIViewController (instead of the UITableViewController) and keeping the UITableView as my property. I applied the necessary methods of the DataSource and Delegate protocols. But when I click the "Edit" button, I do not see any deletions (red minus signs) for my cells, so that I can select them for deletion. The same thing works fine if I use the UITableViewController. I have completed the following methods.

What am I missing, that it does not behave the way it is done using the standard UITableViewController?

- (void)setEditing:(BOOL)editing animated:(BOOL)animated { [super setEditing:editing animated:animated]; self.navigationItem.rightBarButtonItem.enabled = !editing; } - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleDelete; } 
+4
source share
1 answer

It needs to switch the UITableView to edit state:

 [self.tableView setEditing:YES animated:YES]; 
+5
source

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


All Articles