iOS 11 UITableView 删除行动画bug [英] iOS 11 UITableView delete rows animation bug

查看:34
本文介绍了iOS 11 UITableView 删除行动画bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tableview 动画错误视频

我有一个表格视图可以展开/折叠其单元格.

I have a table view which expands/collapse its cells.

从 iOS 11 开始,tableView 在插入和删除行时开始表现得很奇怪.contentSize 在动画块发生之前已更改,因此,在视频中,您可以看到在折叠单元格上发生错误的回滚.动画看起来不对.

As of iOS 11, the tableView starts to behave strangely on insertion and deletion of rows. The contentSize has changed before the animation block happens and consequently, in the video, you can see a buggy scroll back happening on collapsing cells. The animation just looks wrong.

此代码在 iOS 10 上运行良好.有人知道 Apple 方面发生了什么变化吗?这是一个已知的问题?

This code worked perfectly on iOS 10. Do anyone know what has changed on Apple's side? Is this a known issue?

public func insertingRowsForAccordion(_ indexArray: [IndexPath], selectedRowIndex: Int) {
    beginUpdates()
    insertRows(at: indexArray, with: UITableViewRowAnimation.fade)
    endUpdates()

 // Scroll to selection after expanding children
    scrollToRow(at: IndexPath(row: selectedRowIndex, section: 0), at: UITableViewScrollPosition.top, animated: true)
}

public func removeRowsForAccordion(_ indexArray: [IndexPath]) {
    beginUpdates()
    deleteRows(at: indexArray, with: UITableViewRowAnimation.fade)
    endUpdates()
}

推荐答案

我在使用 iOS 11 UITableView 时遇到了无数问题.转到整个应用程序中的每个 UITableView 并执行以下操作解决了我的所有问题.

I have been having countless problems with iOS 11 UITableView. Going to every UITableView in my entire app and doing the following fixed all of my problems.

estimatedRowHeightestimatedSectionHeaderHeightestimatedSectionFooterHeight 设置为 0.

Set estimatedRowHeight, estimatedSectionHeaderHeight, and estimatedSectionFooterHeight to 0.

来源:iOS 11 Floating TableView Header

这篇关于iOS 11 UITableView 删除行动画bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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