我有两个数组。每个 Array 都有一个部分。当用户滑动该行并选择删除时,它必须删除右侧部分中的相应行。如何更改我的代码以使其在正确的部分中删除。到目前为止,这是我的代码。
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//remove the deleted object from your data source.
//If you're data source is an NSMutableArray, do this
if (self.numberOfSections == 1)
{
[self.playerNames removeObjectAtIndex:indexPath.row];
}
else
{
//code here needs to determine which section needs to be deleted
}
[self.tableView reloadData];
}
}