在动画期间阻止UITableViewCell布局 [英] Prevent UITableViewCell layout during animation

查看:96
本文介绍了在动画期间阻止UITableViewCell布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆