UITableView在编辑模式下将单元格添加到底部
我试图让我的表在表的底部添加一个单元格以添加单元格,我的表处于删除模式,因此人们可以删除,但我需要它添加一个带有insert的单元格以插入单元格。我收到错误,说我的应用程序与nsarray不一致。我如何才能做到这一点?步骤1在tableViewController上覆盖SetEdit以插入或删除添加行UITableView在编辑模式下将单元格添加到底部,uitableview,nsarray,Uitableview,Nsarray,我试图让我的表在表的底部添加一个单元格以添加单元格,我的表处于删除模式,因此人们可以删除,但我需要它添加一个带有insert的单元格以插入单元格。我收到错误,说我的应用程序与nsarray不一致。我如何才能做到这一点?步骤1在tableViewController上覆盖SetEdit以插入或删除添加行 - (void)setEditing:(BOOL)editing animated:(BOOL)animate { BOOL prevEditing = self.editing;
- (void)setEditing:(BOOL)editing animated:(BOOL)animate
{
BOOL prevEditing = self.editing;
[super setEditing:editing animated:animate];
[tableView setEditing:editing animated:animate];
if (editing && !prevEditing) {
// started editing
[self.tableView insertRowsAtIndexPaths:....] withRowAnimation:UITableViewRowAnimationFade];
} else if (!editing && prevEditing) {
// stopped editing
[self.tableView deleteRowsAtIndexPaths:....] withRowAnimation:UITableViewRowAnimationFade];
}
}
然后确保返回的行数正确
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSInteger numberOfRows = xxxxxx;
if (self.editing) {
numberOfRows++;
}
return numberOfRows;
}