Removing UITableView sections combined with custom UIViews section headers = bug in Apple code?

I am trying to remove a section from a UITableView using animation and custom UIViews table header header.

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 great when I provide the section headers using

tableView:titleForHeaderInSection:

      

But when I provide my own header using

tableView:viewForHeaderInSection:

      

Deletes the desired section and shifts all sections below it. What I think is happening is the request for a new custom header just before the delete animation. So it animates the removal of the desired Row + 1.

Ultimately, each section shifts one and an empty section at the bottom.

If I scroll down to the bottom of the table, go back and the sections are found again.

I don't think this is something I can fix. It looks like a problem with Apple code stripping with custom section headers. It's usually best to blame yourself first :). I am using the same logic to find the model object for my own section headers and NSString section headers, so I don't see how this could be a problem with my code.

Does anyone know how to fix this, or should I revisit my use of partitions?

+2


source to share


1 answer


I solved this problem by calling reloadSections: atIndexPath: This is one way. Other ways: Refresh the table (you might lose the animation) Using a fetch controller and some property in the U header view. When u deletes one object, the fetch controller can do a partition reload for u.



0


source







All Articles