iOS:将表格单元格移动到另一个部分
我有一个带有一些部分和行的 UITableView。
当我调用函数时,我想将一行从一个部分移动到另一部分(所以不是我的手指,我不想使用 UITableView 的编辑模式)。
我该怎么做?
如果我重新创建数据源并重新加载表,那就可以了,但它不使用动画。
I have a UITableView
with some sections and rows.
I want to move one row from one section to another section, when I call a function (so not my fingers and I do not want use edit mode of UITableView
).
How can I do this?
If I recreate a datasource and reload table, it's ok, but it not use animation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UITableView
为您提供了执行此操作的方法:调用
beginUpdates
、更新数据源、调用 moveRowAtIndexPath 并最终在UITableView
上调用endUpdates
编辑:moveRowAtIndexPath 仅适用于 iOS 5+
所以你宁愿使用这个:
UITableView
offers you methods for this:call
beginUpdates
, update your datasource, call moveRowAtIndexPath and finally callendUpdates
onUITableView
EDIT: moveRowAtIndexPath is only for iOS 5+
so you would rather use this: