Ios UITableView滑动以删除问题(使用单独的数据源对象时)
我有一个问题,我的表格视图在单元格滑动时没有显示删除按钮 我创建了一个单独的数据源类,它符合Ios UITableView滑动以删除问题(使用单独的数据源对象时),ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有一个问题,我的表格视图在单元格滑动时没有显示删除按钮 我创建了一个单独的数据源类,它符合UITableViewDataSource协议。我有一个UITableViewController,我正在使用uipoperpresentationcontroller演示它。当然,在演示之前,我使用数据源所需的所有信息设置数据源,并确保它实现: - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)
UITableViewDataSource
协议。我有一个UITableViewController
,我正在使用uipoperpresentationcontroller
演示它。当然,在演示之前,我使用数据源所需的所有信息设置数据源,并确保它实现:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
在我的UITableViewController
子类中,我还确保实现这两个功能:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// do something (this doesn't get hit yet anyway, as delete button does not appear)
}
}
问题似乎在于,从未调用过方法tableView:editingStyleForRowAtIndexPath:
。但是,如果我绕过单独的datasource类,只在我的UITableViewController
子类中实现datasource,我注意到这个方法确实会被调用
我更愿意弄清楚为什么使用单独的数据源类会给我带来刷卡删除的问题,而不是放弃这个类(我在整个应用程序中都在不可编辑的表视图中使用这个类),而是选择将数据源完全保留在
UITableViewController
子类中。如有任何关于在何处查找的指示,将不胜感激 您需要在.m文件中添加以下tableView数据源方法
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;
非常感谢你。看起来我脑子里出了个屁,实际上,我忘了这是一个数据源,而不是一个委托方法。