iOS11 UITableview reloadRowsAtIndexPaths故障

问题描述 投票:2回答:4

任何人都可以帮助我理解或解决iOS11中的这个UITableView故障。我设法在一个相当简单的测试用例中重现了我的问题。

https://github.com/trapper-/iOS11-tableview-glitch

当重新加载靠近tableview底部的单元格时,重新加载的单元格将开始奇怪地滚动,其他单元格开始移动并跳转。

重新加载多个单元格时会变得更糟,但我不想让这个简单的例子复杂化。

  • 编辑:此问题仅发生在iOS11中,在iOS10和iOS12中正常运行。因此,您需要下载iOS11模拟器以在Xcode 10中进行测试
ios uitableview autolayout ios11
4个回答
5
投票

这应该有所帮助:

[UIView performWithoutAnimation:^{
    [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}];

3
投票

如果我像这样使用它的工作。

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}

3
投票

尝试在viewDidLoad上向表视图提供estimatedRowHeight为0。这个对我有用。


0
投票

请尝试设置你的表视图estimatedRowHeight(在viewDidLoad方法中):self.tableView.estimatedRowHeight = 100;

默认情况下tableView.rowHeight设置为UITableViewAutomaticDimension,但您需要设置estimatedRowHeight From apple - “要启用自调整表格视图单元格,您必须将表格视图的rowHeight属性设置为UITableViewAutomaticDimension。您还必须为estimatedRowHeight指定值一旦设置了这两个属性,系统就会使用自动布局来计算行的实际高度。“

你可以看看:https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/WorkingwithSelf-SizingTableViewCells.html

© www.soinside.com 2019 - 2024. All rights reserved.