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:
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)];
}];
}