Reputation: 616
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.
Is there a way to exclude the layout of the cell from the animation?
Upvotes: 7
Views: 1014
Reputation: 405
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];
}];
}
Upvotes: 8