直接调用 UITableViews 委托方法
我正在寻找一种直接调用编辑方法的方法。
- (void)tableView:(UITableView *)theTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
我拥有用于动画操作单元的所有逻辑,从我的模型数组中删除 等等在这个方法中。当用户滑动、添加或重新排列时会调用它,但我想调用 它手动/直接作为后台线程更改我的模型。
我已经构建了一个像这样的 NSIndexPath :
NSIndexPath *path = [NSIndexPath indexPathForRow:i inSection:1];
我只是不知道如何调用类似的东西:
[self.tableview commitEditingStyle:UITableViewCellEditingStyleDelete forRowAtIndexPath:path];
我是否需要以另一种方式访问这个普通样式 UITableView 的方法?
谢谢:)
I was looking for a way to call the edit method directly.
- (void)tableView:(UITableView *)theTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
I have all my logic for animating manipulated cells, removing from my model array
etc. in this method. It is getting called when a user swipes, adds or rearranges, but I would like to call
it manually/directly as a background thread changes my model.
I have constructed an NSIndexPath like so:
NSIndexPath *path = [NSIndexPath indexPathForRow:i inSection:1];
I just can't figure out how to call something like:
[self.tableview commitEditingStyle:UITableViewCellEditingStyleDelete forRowAtIndexPath:path];
Do I need to gain access to the methods of this plain style UITableView in another way?
Thanks:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只想执行代码,我不明白为什么您不能调用该方法。该文档给出了一个重要的提示,
无论如何都会产生调用该数据源方法的效果。如果您确实想要这样做,那么将您的代码从该方法重构为另一个方法并从数据源方法和代码中的其他位置调用它会更有意义。
如果您确实只想反映模型中的更改,请调用
[tableView reloadData]
- 这就是它的用途。I don't see why you can't call that method, if all you want is for your code to be executed. The docs give a heavy hint that
will have the effect of calling that data source method anyhow. It would make better sense to refactor your code from that method into another method and call it both from the data source method and from elsewhere in your code, if that's really what you want to do.
If you really want to just reflect changes in your model, then call
[tableView reloadData]
- that's what it's for.我不确定,但也许如果您调用该方法
,则可能会调用 commitEditingStyle 方法。
I don't know it for sure but maybe if you call the method
it could be, that the commitEditingStyle method is called.