首页 文章

无法使用Three20删除表中的行

提问于
浏览
3

我有一个按钮,可以在TTTableView上切换setEditing . 以前我一直在使用“常规”UITableView和以下方法来实际删除数据,但我在Three20类中看不到任何类似的东西,并且在按下删除按钮时不会调用我的方法行 .

  • (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {// do work}

我必须遗漏一些东西,但我无法弄清楚在哪里 . 似乎TTTableViewController中的setEditing没有连接到任何东西 . 有一个didDeleteObject方法,但我不知道是否应该替换上述方法 . 任何投入将不胜感激 .

1 回答

  • 7

    您对 TTTableViewController 的体验也会比您预期的略有不同,因为它不会从 UITableViewController 继承 . 与大多数具有表视图控制器的iPhone教程也实现UITableViewDelegateUITableViewDataSource协议不同,Three20通过单独的类实现它们:您应该使用模型实例设置控制器的 dataSource 属性,并且控制器创建自己的委托(在 createDelegate 中)方法,你可以覆盖) .

    您要实现的方法tableView:commitEditingStyle:forRowAtIndexPath:UITableViewDataSource 协议的一部分,因此您需要在模型类上实现它,而不是在控制器本身上实现 .

    TTTableViewController 不直接对 setEditing:animated: 做任何事情,只是从UIViewController继承基本实现 .

    您看到的 model:didDeleteObject: 方法继承自 TTModelViewController 作为 TTModelDelegate 协议的实现 . 它's there so that changes to the underlying data model can notify the view layer of changes. For instance, if your application is downloading data from the web, rows may appear and disappear all the time, independent of what'继续用户界面 . 如果你需要捣乱那个 .

相关问题