moveRowAtIndexPath不刷新单元格的内容 [英] moveRowAtIndexPath doesn't refresh the cell's content

查看:77
本文介绍了moveRowAtIndexPath不刷新单元格的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS 5最终将 moveRowAtIndexPath:toIndexPath:方法添加到 UITableView 。问题是,调用它只会移动行,它不会更新/重绘它。这样做的唯一方法似乎是找到单元格并直接调用setNeedsDisplay。但这很棘手,因为你永远不知道细胞是否已被移动。

iOS 5 finally added a moveRowAtIndexPath:toIndexPath: method to UITableView. Problem is, calling it only moves the row, it doesn't update/redraws it. The only way to do so seems to be by finding the cell and calling setNeedsDisplay directly. But this is tricky since you never know whether the cell already got moved or not.

我无法调用 reloadRowsAtIndexPaths:要么,因为我不允许在同一个 beginUpdates-endUpdates 块内的一行中应用2个动画。

I can't call reloadRowsAtIndexPaths: either, since I'm not allowed to have 2 animations applied to a single row inside the same beginUpdates-endUpdates block.

我可以想到可能的解决方法,比如将整个事物分成2个动画块。但我想知道我是否遗漏了一些东西,因为整个行为对我来说似乎很奇怪。

There are may workarounds I can think of, like splitting the whole thing into 2 animation blocks. But I'm wondering whether I'm missing something, as the whole behavior seems odd to me.

推荐答案

最后收到一个官员Apple对此问题的回答:

Finally received an official answer from Apple regarding this issue:


工程已根据以下信息确定此问题基于
的预期行为:

Engineering has determined that this issue behaves as intended based on the following information:

只有插入和更新导致从数据
源请求单元格(第一个因为它是新的而第二个因为你已经明确地告诉了
用于更新单元格的表视图)。删除并移动
不更新内容,因为在执行的
操作中并非隐含。如果您需要在更新期间更改单元格
的内容,只需进入单元格并更改内容。

Only insert and update cause the cell to be requested from the data source (the first because it's new and the second because you've explicitly told the table view to update the cell). Delete and move don't update the contents because that's not implicit in the action being performed. If you need to change the contents of the cell during the update, just reach into the cell and change the contents.

这篇关于moveRowAtIndexPath不刷新单元格的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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