Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent UITableViewCell layout during animation

I have an UIViewController with an UITableView inside of an UINavigationController.
When I hide the navigation bar with

[self.navigationController setNavigationBarHidden:YES animated:YES];

the table view is resized and a new cell is displayed at the bottom. This cell layouts it's subviews inside of the animation that hides the navigation bar.

Cell Animation

Is there a way to exclude the layout of the cell from the animation?

like image 797
Jochen Avatar asked Jul 15 '15 16:07

Jochen


1 Answers

You can prevent the cell from animating by implementing the UITableViewDelegate method tableView:willDisplayCell:forRowAtIndexPath: as such:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    [UIView performWithoutAnimation:^{
        [cell layoutIfNeeded];
    }];
}
like image 125
emb Avatar answered Nov 15 '22 06:11

emb