无法使用Three20删除表中的行 [英] Unable to delete rows in table using Three20

查看:49
本文介绍了无法使用Three20删除表中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我一定想念一些东西,但我不知道在哪里.似乎TTTableViewController中的setEditing没有连接任何东西.有一个didDeleteObject方法,但我不知道这是否应该替代上述方法.任何输入将不胜感激.

解决方案

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

您要实现的方法,

I must be missing something but I can't figure out where. It seems like setEditing in TTTableViewController isn't connected up to anything. There's a didDeleteObject method but I've no idea whether that's supposed to be a replacement for the above method or not. Any input would be greatly appreciated.

解决方案

Your experience with TTTableViewController is also going to be a little different than you might expect because it does not inherit from UITableViewController. Unlike most iPhone tutorials that have the table's view controller also implement the UITableViewDelegate and UITableViewDataSource protocols, Three20 implements them through separate classes: you are expected to set the controller's dataSource property with a model instance, and the controller creates its own delegate (in the createDelegate method, which you can override).

The method you want to implement, tableView:commitEditingStyle:forRowAtIndexPath:, is part of the UITableViewDataSource protocol, so you're going to need to implement that on your model class, and not on the controller itself.

The TTTableViewController does not directly do anything with setEditing:animated:, and just inherits the base implementation from UIViewController.

The model:didDeleteObject: method that you see is inherited from TTModelViewController as an implementation of the TTModelDelegate protocol. It'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's going on with the user interface. If you're trying to drive edits through the UI, you shouldn't need to mess with that.

这篇关于无法使用Three20删除表中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆