Ios 在UITableView中删除行,但不要使用删除按钮
我有一个问题,我想删除UITableView中的行,但不使用滑动按钮删除。我想要调用函数Ios 在UITableView中删除行,但不要使用删除按钮,ios,iphone,uitableview,nsindexpath,Ios,Iphone,Uitableview,Nsindexpath,我有一个问题,我想删除UITableView中的行,但不使用滑动按钮删除。我想要调用函数removeCellafter条件。我的问题是无法删除UITableView中的第一行,因为我不知道要删除的行的get indexPath 如果我滑动删除按钮,它工作得很好但我不想使用删除按钮。 - (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle for
removeCell
after条件。我的问题是无法删除UITableView中的第一行,因为我不知道要删除的行的get indexPath
如果我滑动删除按钮,它工作得很好但我不想使用删除按钮。
- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
deleteindexPath = indexPath;
/*[_tableView beginUpdates];
if (editingStyle == UITableViewCellEditingStyleDelete) {
[_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
[_tableView endUpdates];*/
[self removeCell];
}
removeCell():
我尝试设置deleteIndexPath=[\u tableView indexPathForCell:cell]代码>在cellforrowatinexpath()
中,但不工作,崩溃
你有什么建议吗 试试这个
-(void) removeCell
{
[_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:deleteIndexPath] withRowAnimation:UITableViewRowAnimationFade];
//Now remove data from your tableArray also..
[_tableView reloadData];
}
那么您想如何调用这个removeCell
method?您有哪些节?您使用哪个数组来填充tableview?
-(void) removeCell
{
[_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:deleteIndexPath] withRowAnimation:UITableViewRowAnimationFade];
//Now remove data from your tableArray also..
[_tableView reloadData];
}