无法使用Three20删除表中的行 [英] Unable to delete rows in table using Three20
问题描述
我有一个按钮可以在TTTableView上切换setEditing.以前,我一直在使用常规" UITableView和以下方法来实际删除数据,但在Three20类中没有看到类似的东西,并且在按行.
- (无效)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { //工作}
我一定想念一些东西,但我不知道在哪里.似乎TTTableViewController中的setEditing没有连接任何东西.有一个didDeleteObject方法,但我不知道这是否应该替代上述方法.任何输入将不胜感激.
您对 您要实现的方法, 您看到的 I've got a button that toggles setEditing on a TTTableView. Previously I'd been using a "regular" UITableView and the following method to actually delete the data, but I don't see anything similar in the Three20 classes and using my method doesn't get called when the delete button is pressed on a row. 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 The method you want to implement, The The 这篇关于无法使用Three20删除表中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!TTTableViewController
的体验也将与您预期的有所不同,因为它不会从UITableViewDelegate
和 UITableViewDataSource
协议,Three20通过单独的类来实现它们:您应该使用模型实例设置控制器的dataSource
属性,并且控制器创建自己的委托(在createDelegate
方法中,可以重写).>
UIViewController
.model:didDeleteObject:
方法是作为TTModelDelegate
协议的实现而从TTModelViewController
继承的.在那里,对基础数据模型的更改可以通知更改的视图层.例如,如果您的应用程序正在从Web下载数据,则行可能会一直出现和消失,而与用户界面的状况无关.如果您要尝试通过用户界面进行编辑,则无需为此烦恼.
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).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.TTTableViewController
does not directly do anything with setEditing:animated:
, and just inherits the base implementation from UIViewController
.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.