views:

441

answers:

3

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.)

A: 

Can observe the same behavior, really odd, any progress so far? A [tableView reloadData] doesn't solve the problem because the animation gets broken...

alex

alex
No progress. Then again, I have tabled it for a bit! (Ow. No pun intended.)
Joe D'Andrea
A: 

Have you tried to change something in the footer in the method you call from your footer buttons e.g. changig text on a UILabel in the footer? That's what I try to do. BUT: The footer is not updated. Or to be more precise: It is updated, but not on the screen. Scrolling the footer out of the visible array and back shows the correct footer. So there is an update problem.

So perhaps you see the same redraw-Problem?

I tried to call all the methods (needslayout needsDisplay etc etc) nothing worked. The only way to solve this is a table or section reload, but this kills my rowAnimation. Next I tried to call the reload via a notification hoping the animation is finished before the notification is called. Nope. At the end I use a scheduled timer to reloadData with 100-200ms delay started at the aned of my insert/delete rows. So the animation is finished before the load.

It looks like it is working now, but the price is a short "flash" with a wrong footer before it gets updated.

UPDATE

Ok, with the support of Skie I solved my redraw problem. Please refer to: http://stackoverflow.com/questions/2713884/uitableview-section-header-and-section-footer-not-updating-redraw-problem

I'm not sure if this approach or at least the idea can solve yours too, but perhaps....

Gerd
Bingo. There's an update problem, and you just uncovered a more explicit way to spot it! This has got to be related to what I'm seeing. If I instigate a reload, you're also correct - rowAnimation goes kablooey. Very slick workaround you've proposed too, though I never thought I'd see the return of the FOUC (Flash of Unstyled Content) previously reserved only for web pages. :)
Joe D'Andrea
Comment to update: Interesting! I can say this much. I'm using two buttons in my footer, but in my case I see the entire button, and both buttons work just fine. They're being allocated the proper way, etc. … also, there are no memory leaks - between static analysis, our own spot checking, and looking at Instruments info. Moreover, the same buttons - if moved to the header - don't exhibit the same problem. Verrry interesting though.
Joe D'Andrea
As I wrote, my initial problem is solved but now I spot the same disppearing footer from time to time.... However I see it (until now) happens only on the simulator, not on a iPhone 1.Gen or a 3GS. But "Noch ist nicht aller Tage Abend..." (meaning it probably will come some day) as we say in Germany.
Gerd
A: 

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.

Gerd