1

I'm building a UITableView with cells that "slide out" an additional view below when selected. To do this, I've animated the row heights in the table view using [tableview beginUpdates] and [tableView endUpdates] then I'm animating the sliding view to translate along with that animation to look like it's being uncovered. The animation I'm using works fairly well, but is just a little off from how the row heights are moving.

For example, this is my cell. Normally, only the white part (blue because of the highlight) shows, but if you select a row, the gray view slides out from the bottom like an action menu for that row with a couple buttons:

enter image description here

What I want to know is: What are the animation settings used by default for the table view's BeginUpdates/EndUpdates methods, or if that's unknown, is there anyway I could set them custom so my row heights and sliding view are animating exactly the same?

tableView methods:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([[tableView indexPathForSelectedRow] isEqual:indexPath])
        return CellHeightAlternate;
    return CellHeightNormal;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    SlideOutViewTableViewCell *newCell  = (SlideOutViewTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];

    [tableView beginUpdates];
    [tableView endUpdates];

    [newCell showView];
}

SlideOutTableViewCell showView Method:

- (void)showView{
    [self.slideoutView setFrame:CGRectMake(self.slideoutView.frame.origin.x, 40, self.slideoutView.frame.size.width, self.slideoutView.frame.size.height)];
    [UIView animateWithDuration:.25 animations:^{
        [self.slideoutView setFrame:CGRectMake(self.slideoutView.frame.origin.x, 70, self.slideoutView.frame.size.width, self.slideoutView.frame.size.height)];

    }];
}
Matt Cooper
  • 2,042
  • 27
  • 43
  • Sorry..i didn't understand nothing. P.S. why do you use `[tableView beginUpdates]` and `[tableView endUpdates]` without nothing in? – Matteo Gobbi May 19 '14 at 22:21
  • @MatteoGobbi I got that code from this question: http://stackoverflow.com/questions/460014/can-you-animate-a-height-change-on-a-uitableviewcell-when-selected. If there's nothing between them it still calls a redraw on the cells and animates the change that occurs in `- tableView: heightForRowAtIndexPath:` when a different cell is selected – Matt Cooper May 19 '14 at 23:32

1 Answers1

3

So I found the answer through trial and error:

The animation with which the table view changes the row heights (from the [tableview beginUpdates] and [tableView endUpdates] methods) is a linear animation (no animation effects) with a duration of .3 seconds.

Matt Cooper
  • 2,042
  • 27
  • 43