【问题标题】:Prevent UITableViewCell layout during animation在动画期间防止 UITableViewCell 布局
【发布时间】:2015-07-15 16:26:04
【问题描述】:

我有一个UIViewController,在UINavigationController 内有一个UITableView
当我用

隐藏导航栏时
[self.navigationController setNavigationBarHidden:YES animated:YES];

调整表格视图的大小,并在底部显示一个新单元格。 这个单元格在隐藏导航栏的动画内布局了它的子视图。

有没有办法从动画中排除单元格的布局?

【问题讨论】:

    标签: ios objective-c uitableview cocoa-touch


    【解决方案1】:

    您可以通过实现 UITableViewDelegate 方法tableView:willDisplayCell:forRowAtIndexPath: 来阻止单元格动画:

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        [UIView performWithoutAnimation:^{
            [cell layoutIfNeeded];
        }];
    }
    

    【讨论】:

    • 谢谢!除了披露指标之外,它对所有内容都非常有效。在cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 周围使用performWithoutAnimation: 也解决了这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多