在动画期间阻止UITableViewCell布局 [英] Prevent UITableViewCell layout during animation
问题描述
我有一个 UIViewController
与 UITableView
在 UINavigationController
。
当我用
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?
推荐答案
您可以通过实现UITableViewDelegate方法来阻止单元格动画 tableView:willDisplayCell:forRowAtIndexPath:
:
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];
}];
}
这篇关于在动画期间阻止UITableViewCell布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!