我一直在努力将滑动删除功能添加到UITableView我的应用程序中的普通文本中,但没有成功。
我有一个UIViewController包含唯一的 a UITableView,它使用基本单元格和自定义单元格。这UIViewController是在 a UINavigationControllerwhich is centerViewControllerof a之上IIViewDeckController
的委托和数据源UITableView设置正确,这是当前代码:
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"canEditRowAtIndexPath");
return YES;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"commitEditingStyle");
}
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"editingStyleForRowAtIndexPath");
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tv didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"didEndEditingRowAtIndexPath");
}
其他委托方法cellForRowAtIndexPath,如canEditRowAtIndexPath 和didSelectRowAtIndexPath被正确调用,但editingStyleForRowAtIndexPath从未在任何单元格上被调用。
更新
当我这样做[table setEditing:YES animated:YES];时,它确实启用了编辑模式。
这里可能缺少什么?