iphone - 无法使用 Three20 删除表中的行

标签 iphone uitableview three20

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

  • (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { //做工作}

我一定错过了一些东西,但我不知道在哪里。 TTTableViewController 中的 setEditing 似乎没有连接到任何东西。有一个 didDeleteObject 方法,但我不知道它是否应该替代上述方法。任何意见将不胜感激。

最佳答案

您使用 TTTableViewController 的体验也会与您预期的有所不同,因为它继承自 UITableViewController。与大多数具有表格 View Controller 的 iPhone 教程不同,它也实现 UITableViewDelegateUITableViewDataSource协议(protocol),Three20 通过单独的类实现它们:您需要使用模型实例设置 Controller 的 dataSource 属性,并且 Controller 创建自己的委托(delegate)(在 createDelegate 方法中,您可以覆盖它)。

您要实现的方法,tableView:commitEditingStyle:forRowAtIndexPath: ,是 UITableViewDataSource 协议(protocol)的一部分,因此您需要在 model 类上实现它,而不是在 Controller 本身上实现。

TTTableViewController 不会直接对 setEditing:animated: 执行任何操作,而只是继承 UIViewController 的基本实现。 .

您看到的 model:didDeleteObject: 方法是从 TTModelViewController 继承的,作为 TTModelDelegate 协议(protocol)的实现。它的存在使得底层数据模型的更改可以通知 View 层更改。例如,如果您的应用程序正在从网络下载数据,则行可能会一直出现和消失,而与用户界面的情况无关。如果您尝试通过 UI 进行编辑,则不需要搞乱它。

关于iphone - 无法使用 Three20 删除表中的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1384659/

相关文章:

iphone - 有没有 TTPickerTextField 替代方案?也许在iOS4中?

objective-c - 添加额外的 UIImage 到 TTPhotoViewController

iphone - UIImagePickerController 并从现有照片中提取 EXIF 数据

iphone - 在导航 Controller 中添加选项卡栏 Controller 时隐藏后退按钮

ios - 在 Swift 中使用另一个文件中的单元格

ios - 在 UITableViewCell tap 上显示和隐藏 DatePicker

iphone - 如何将UINavigationBar子类化以与Three20/iOS5一起使用?

iphone - iOS - 将自定义 UIView 放入 View Controller 中

iphone - applicationWillResignActive 和 setBrightness 不起作用?

iOS 在 TableView 中显示的标题截断从 titleForHeaderInSection 返回的字符串