3

I have a custom tableFooterView (it's just an 8px high CoreGraphics arc with a gradient) that I set with the tableFooterView property in viewDidLoad rather than viewForFooterInSection. When setting it with viewForFooterInSection, it floated over the content when it reached the bottom, whereas tableFooterView does what I want it to in that it stays with the UITableView's height.

But when the cells or table view do change in height, the tableFooterView animates to them slowly (about half a second but it's very noticeable). This is pretty awkward since the footer is supposed to look like an extension of the last cell. For instance, when heightForRowAtIndexPath changes the height of a cell, the tableFooterView kind of ghost-floats back. In this screenshot the bottom cell has just been shrunken to its normal size and the footer is floating back.

(As a new user I can't post images but here's the link: http://desmond.imageshack.us/Himg835/scaled.php?server=835&filename=iossimulatorscreenshotj.png&res=landing)

(This content is no longer available, 14/9/15).

It will also float over the content when the height of the last cell is suddenly changed to be larger than it was.

Any pointers? Thanks very much.

Edit: By cells changing in height, I mean through the heightForRowAtIndexPath section:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    Note *currentNote = [self.notes objectAtIndex:indexPath.row];
    if (currentNote.associatedCellIsSelected) {
        return NORMAL_CELL_FINISHING_HEIGHT*2;
    }

    return NORMAL_CELL_FINISHING_HEIGHT;
}

Edit 2: In didSelectRowAtIndexPath I make the cell selected (actually the cell's note), begin / end updates as well as call reloadRow for the row that's been selected.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

Note *currentNote = [self.notes objectAtIndex:indexPath.row];

if (currentNote.associatedCellIsSelected == FALSE) {
    currentNote.associatedCellIsSelected = TRUE;
    [tableView beginUpdates];
    [tableView endUpdates];
}

[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];    }

I've also made sure that I get the same behavior with a plain rect redColor UIView in place of the Core Graphics footer, with the same results. I wish there was just an easy way to override the footer and tell it to not animate!

holex
  • 23,961
  • 7
  • 62
  • 76
Zack
  • 187
  • 1
  • 7
  • it's hard to find the problem without having a look at the code, i saw the link but i don't understand what you are exactly trying to do. What do you mean by "when the cells or table view do change in height". You mean when you scroll the tableview? – self Jun 01 '12 at 21:23
  • @AIbrahimZ Sorry, I meant just through using heightForRowAtIndexPath. I've included the code in an edit. When the cell doubles in height (without animating), the footer scrolls to it slowly. And when the cell shrinks back to normal size (again without animating), the footer does what you see in the image link. – Zack Jun 02 '12 at 15:57
  • Have you tried to comment your CoreGraphics code and set just different background color? Maybe it is caused by slow drawing. – Martin Pilch Jun 02 '12 at 16:00
  • @MartinPilch I have, with the same results. :( – Zack Jun 02 '12 at 16:20
  • How do you update the table when the height changes? With `reloadData`? Did you make a test with a static footer? – Mundi Jun 03 '12 at 10:10
  • @Mundi I've made a new edit, I don't call reloadData when changing the height but I do call reloadRowsAtIndexPaths as well as begin / end updates. The actual height value is located in cellForRow within an if (cell.associatedNoteIsSelected). And if by static footer you mean just a regular UIView instead of Core Graphics, I have tried that with no luck. – Zack Jun 03 '12 at 15:46

0 Answers0