ios - 在动画期间防止 UITableViewCell 布局

标签 ios objective-c uitableview cocoa-touch

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

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

表格 View 被调整大小,一个新的单元格显示在底部。 此单元格将其 subview 布局在隐藏导航栏的动画中。

Cell Animation

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

最佳答案

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

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

关于ios - 在动画期间防止 UITableViewCell 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31435958/

相关文章:

iphone - Objective C/iPhone - Date Time Picker 如何格式化它的日期(例如 strip YYYY)以及如何检索这些格式?

iphone - iOS图像比较

ios - 多选模式下的 UITableView 删除所选单元格中所有 subview 的背景颜色

ios - 无限循环 UITableView

ios - Xcode 5 中的导航栏问题

ios - urlContentArray[1].componentsSeparatedByString ("</span>")

ios - 退化的顶点和 GL_LINE_STRIP

ios - 无法保存数据 --- Swift、IOS、Core 数据 --- 线程 1 : signal SIGABRT

objective-c - 无法构建 Objective-c 模块?

ios - 如何在 Swift 中删除 UITableView 中的行