0
我想弄清楚我的表格視圖發生了什麼。當我在編輯模式下刪除一行時,它可以順利運行,但是當刪除模式滑動時,它會崩潰。didEndEditingRowAtIndexPath得到零
我在每個功能並以某種方式和有效的對象nil
的indexPath
變化之間comitEditingStyle: atIndexPath
didEndEditingRowAtIndexPath:
設置斷點。
-(void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
editFromSwipe = YES;
[tableView setEditing:YES animated:YES];
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(editingStyle == UITableViewCellEditingStyleInsert)
{
[self addNewNoteToGroup:[NSNumber numberWithInt:[indexPath section]]];
}
else if(editingStyle == UITableViewCellEditingStyleDelete && !editFromSwipe)
{
[[noteGroupsList objectAtIndex:[indexPath section]] deleteNoteAtIndex:[indexPath row]];
}
}
-(void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
[notesTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
editFromSwipe = NO;
[tableView setEditing:NO animated:YES];
}
這是我在做什麼,但它總是崩潰,所以我我認爲我做錯了,回到我認爲的文檔... – Clay