在没有编辑按钮的情况下在tableview中编辑操 [英] edit action in tableview without Edit button?

查看:76
本文介绍了在没有编辑按钮的情况下在tableview中编辑操的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的tableview中显示所有行(加载时),在 UITableViewCellStateShowingDeleteConfirmationMask 中显示红色标记(负号)。换句话说,如果我点击红色标记,它必须在表格视图中显示该特定行的删除按钮(编辑按钮的操作将不按编辑按钮)。下面的代码给出了一个运行时错误,并且它没有显示每一行的负红色标记?

i want to show all rows in my tableview(when it loads) with red mark (negative symbol) in UITableViewCellStateShowingDeleteConfirmationMask. In other words if i click red mark ,it must show delete button for that particular row (edit button's action will be taken without pressing edit button) in table view. The following code is giving a run time error and It is not showing the minus red mark as well for each row?

我想在没有编辑按钮的情况下执行此操作我需要做到这一点吗?

I want to do it without an Edit button so what i need to do to achieve it?

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
NSArray *deleteIndexPaths = [NSArray arrayWithObjects: [NSIndexPath indexPathForRow:indexPath.row inSection:0], nil]; 

[tableView beginUpdates];

[tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade]; 

[tv endUpdates];

}


推荐答案

我是不太清楚你究竟想要做什么。但是如果你想进入编辑模式(如果用户按下编辑按钮会发生同样的情况),你只需要打电话:

I am not quite sure what exactly you are trying to do. But if you want to enter edit mode (the same what would happen if the user presses the "edit" button) you simply have to call:

[tableView setEditing:YES animated:YES]

有关详细信息,请参阅UITableView文档。

For more information see UITableView documentation.

这篇关于在没有编辑按钮的情况下在tableview中编辑操的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆