R – Grouped UITableView Footer Sometimes Hidden On Quick Scroll

footerinsertiphonerowuitableview

OK, this one is a puzzler. There is one similar post but it's not similar enough to count, so I'm posting this one. 🙂

I've got a grouped UITableView with a header and footer. The footer includes two UIButton views, side-by-side. Nothing major.

Now … there is a toggle button in a UIToolbar at the bottom for more/less info in this table view. So I build my index paths to delete/insert with fade row animation, all the usual ingredients, sandwiched between beginUpdates and endUpdates calls on the UITableView … and this works fine! In also happens that my footer can sometimes be pushed off past the bottom of the display.

Here's where it gets weird. If I drag my finger up the display, scrolling the view upward, I should see that footer eventually, right?

Well … most of the time I do. BUT, if I flick my finger up, for a faster scroll, the footer is missing. Even if you try to tap in that area – no response.

However, if I scroll back down again, just to hide that footer (or rather hide the area where the footer would normally be), and then scroll back up, it's there once again!

This only happens when inserting rows. If I delete rows, the footer stays put … unless of course it was already hidden and I didn't perform the aforementioned incantation to get it back. :)

I am trying to trace through this, but to no avail. I suppose tracing through scroll operations is a bit of a crazy proposition! Perhaps some creative logging … suggestions, anyone? Or is this a known issue in 3.1 where row insert/deletes are concerned? (I don't recall seeing it until 3.1.)

Best Answer

OK moving ahead with our app, I stumbled more often over the redraw problem. After investigating hours and hours it seems that there is only one solution [tableView reloadData]. But there is a better solution (than in my first answer) for the broken animation. You can get a method call as soon as the animation is finished with this and there is no longer a "flash":

[UIView beginAnimations:nil context:[NSNumber numberWithInt:section]];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
...do something on the table..
and commitAnimation

In your animationDidStop do the table reload.

But it's still tricky to find the correct moment/event for the reload, in particular if you are working with the fetchedResultsController which is firing his delegate methods on his own as soon as a attribute is changed which is used for sorting.

All this is still an exercise of programming around a problem with cell view updating which shouldn't be one.

Related Topic