How to add extra cells in a UITableView in editing mode?

后端 未结 1 1666
终归单人心
终归单人心 2021-01-19 01:17

Do you know how to have some cells appear in a table view after the table goes into editing mode? Just like the \"Contacts\" iPhone app does when you edit a contact.

相关标签:
1条回答
  • 2021-01-19 01:50

    Where did you enter the editing state of the tableView? You should do it in -[UINavigationController setEditing:animated:]:

    - (void)setEditing:(BOOL)editing animated:(BOOL)animated {
        [super setEditing:editing animated:animated];
        [self.tableView setEditing:editing animated:animated];
    
        if(editing){
            [self.tableView insertSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationBottom];
        } else {
            // delete section
        }
    }
    

    So instead of calling setEditing on the tableView, call it on the navigationController (probably self) The controller will then handle the editing mode.

    So the controller has an editing mode, and the tableView has. The tableView will be in editing mode once you set it programmatically, or when the user swipes to delete a row. In the latter case, the controller is not in editing mode, but the tableView is.

    0 讨论(0)
提交回复
热议问题