删除 UITableView 部分与自定义部分标题 UIViews = Apple 代码中的错误?
我正在尝试使用动画和自定义表节标题 UIViews 从 UITableView 中删除一个节。
我使用...
//Deletion from my model done here (not shown) and then perform the deleteSections...
[self.tableView beginUpdates];
[self.tableView
deleteSections:[NSIndexSet indexSetWithIndex:index]
withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
当我使用提供部分标题时效果很好,
tableView:titleForHeaderInSection:
但是当我使用提供我自己的自定义标题时
tableView:viewForHeaderInSection:
它会删除所需的部分并将其下面的所有部分向上移动。我认为正在发生的事情是它在执行删除动画之前要求新的自定义标头。因此它会以动画方式删除desiredRow+1。
我最终将每个部分都向上移动了一位,并在底部有一个空白部分。
如果我滚动到表格底部,然后返回,这些部分会再次正确找到。
我不认为这是我能解决的问题。这似乎是苹果处理带有自定义节标题的节删除的代码中的一个问题。通常,先责怪自己是个好主意:)。我使用相同的逻辑来查找自定义节标题与 NSString 节标题的模型对象,因此我看不出它如何成为我的代码的问题。
有人知道如何解决这个问题或者我应该重新考虑我对部分的使用吗?
I'm trying to delete a section from a UITableView using animation and custom table section header UIViews.
I use...
//Deletion from my model done here (not shown) and then perform the deleteSections...
[self.tableView beginUpdates];
[self.tableView
deleteSections:[NSIndexSet indexSetWithIndex:index]
withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
This works fine when I provide the section titles using
tableView:titleForHeaderInSection:
But when I provide my own custom header using
tableView:viewForHeaderInSection:
It deletes the desired section and shifts all the sections below it up. What I think is happening is it is asking for the new custom header just before it does the deletion animation. So it animates the removal of the desiredRow+1.
I end up with every section shifted up by one and a blank section at the bottom.
If I scroll to the bottom of the table then come back the sections are found properly again.
I don't think this is something I can fix. It seems like a problem in Apple's code handling section deletion with custom section headers. Usually it's a good idea to blame myself first :) . I'm using the same logic to find the model object for my custom section headers vs. the NSString section titles so I cannot see how it could be a problem with my code.
Anyone know how to fix this or should I rethink my use of sections?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了这个问题,调用 reloadSections:atIndexPath:
这是一种单向方式。
其他方式:
重新加载表格(您可能会丢失动画)
在 u 标头视图中使用获取控制器和一些属性。当您删除一个对象获取控制器时,可以为您重新加载部分。
I was solved this issue to call reloadSections:atIndexPath:
This is a one way.
Other ways :
Reload table (you may loose animation)
Using a fetch controller and some property in u header view. When u delete one object fetch controller can do reload sections for u.