編集ボタンを表示させる(selfは、UITableViewController等で下位層のController)
self.navigationItem.rightBarButtonItem = self.editButtonItem
編集モードになった時に、追加ボタンを表示させる
if (self.tableView.isEditing){ let addButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.add, target: self, action: #selector(<class>.<selector>)) self.navigationItem.leftBarButtonItem = addButto } else { ... }
編集モードでの削除への対応は、
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the row from the data source // remove selected row from model ..... // update table view [[self tableView] deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } else if (editingStyle == UITableViewCellEditingStyleInsert) {