只要实现UITableViewDataSource接口中的tableView:commitEditingStyle:forRowAtIndexPath:方法即可。
#pragma mark - #pragma mark Table View Data Source Methods - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; [self.list removeObjectAtIndex:row]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; }
如果UITableView是UITableViewStyleGrouped类型的话,当删除分组中最后一条数据时,该分组也必须删除,否则会报错:
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2372/UITableView.m:1070
libc++abi.dylib: handler threw exception
以下代码示例多个分组,每个分组一条数据的情况
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { [self.list removeObjectAtIndex:indexPath.section]; [tableView beginUpdates]; [tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationFade]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; [tableView endUpdates]; }
相关推荐
在tableview中添加多个view,对view进行删除操作。不更新整个cell
iOS数据库SQLite3基本操作并将内容显示在tableView中
IOS开发 tableview中cell的用法 值得拥有
UITableView的各种操作,详细使用UITableView,附源码。
swift ,使用autolayout + storyboard 最外层tableview列表,cell里面嵌套了tableview,自适应内容,cell里的tableview不可滑动,内容全部显示,且文字分行显示,不用设置cell的高度直接可以自适应内容
Qt Quick Control1中 从5.1版本开始就提供了表格控件,但是感觉不怎么好用,在Qt Quick Control2中 5.12版本开始又提供了一个专门用于做表格的控件TableView,相比于前面的方案,使用Tableview更加简单和直接。...
这是Qt中tableWidget和tableView的简单使用。
包含MYSQL的数据库连接,TableView的表格设置,排序model的使用,数据库数据行数统计,每页只显示10行,每页中的每列可以排序,能删除选定行,增加一行,跳转到第一页、上一页、下一页、最后页,点击单元格可以修改...
QML的tableView中的每列数据以不同的形式进行表现,例如单选框、ComBobox、进度条等进行显示,这样会使数据更加直观。该程序可以直接使用qmlscene进行运行,支持Qt5.5及其以上版本
QT下Mingw实现QTtableview中实现添加复选框、按钮控件实例
WyhSelectedToolBar(自定义navigationToolBar结合tableView进行编辑操作) 内部实现了通过navigationToolBar 对cell进行编辑操作 cell高度自适应 cell可全选删除
ios中tableview下拉出发tableview更新的效果实现。 iPhone5.1 测试成功
IOS中sqlite tableview的demo
多个tableView嵌套 滑动上一个tableView停留,接着滑动下一个tableView
JavaFX的一个demo,带checkbox的tableview,选中一行获取所选中行的数据。
tableView展开
javafx 2.0 tableview 实例 在此例子中有完整的tableview的使用
该工程使用vs2010编译,实现windows先文件夹指定类型扫描,以及扫描到的文件界面展示。主要涉及到Qt托管类的使用方法,以及自定义tableview和model的实现方法。
在ios中实现combox,并在UITableCell中作为子视图。
TableView 解析城市列表 数据来源:Plist文件