UITableView在iOS 11中删除行

UITableView在iOS 11中删除行,ios,uitableview,xcode9,Ios,Uitableview,Xcode9,当我尝试删除行时,一开始它表现得相当好。但是,在内容大小首先小于tableview的边框的情况下,删除行时,整个表突然向上跳1行 这是我的删除行操作 override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { R

当我尝试删除行时,一开始它表现得相当好。但是,在
内容大小
首先小于tableview的
边框
的情况下,删除行时,整个表突然向上跳1行

这是我的删除行操作

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        Results.remove(at: indexPath.row)
        tableView.deleteRows(at: [indexPath], with: .automatic)
    }
}
ViewDidload
中,我已经实现了下面的代码

self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
只有当内容的高度第一次变小到边界时,动画才会出错。。。之后,动画也正常运行

下面是正在发生的事情。。。
这是iOS 11中的一个bug吗

好的,我终于找到了一个解决方案,看起来不错。我将以下代码添加到删除操作:

if(tableView.contentSize.height<=tableView.bounds.height+100.0 && tableView.contentSize.height>tableView.bounds.height) {
    tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: true)
}
// The 100.0f is the cell height.
if(tableView.contentSize.heighttableView.bounds.height){
scrollToRow(位于:IndexPath(行:0,节:0),位于:。顶部,动画:true)
}
//100.0f是单元格高度。

100.0f是单元格的高度。因此,当内容的高度首先小于tableView的边框时,tableView会滚动到最顶端,出现问题的动画会被滚动动画覆盖。

好的,最后我找到了一个解决方案,看起来不错。我将以下代码添加到删除操作:

if(tableView.contentSize.height<=tableView.bounds.height+100.0 && tableView.contentSize.height>tableView.bounds.height) {
    tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: true)
}
// The 100.0f is the cell height.
if(tableView.contentSize.heighttableView.bounds.height){
scrollToRow(位于:IndexPath(行:0,节:0),位于:。顶部,动画:true)
}
//100.0f是单元格高度。

100.0f是单元格的高度。因此,当内容的高度开始小于tableView的边框时,tableView会滚动到最顶端,出现问题的动画会被滚动动画覆盖。

您在真实设备上尝试过这样做吗?哦,没有,但我发现许多人使用其他版本的Xcode,模拟器似乎没有类似的问题。。。所以我想知道的是,某个版本上出现的问题。。。但是我发现这个问题可以通过我下面的答案来解决…所以也许没人问只是因为它太简单了,你有没有在真正的设备上尝试过这样做?哦,没有,但我发现很多人使用其他版本的Xcode,模拟器似乎没有类似的问题。。。所以我想知道的是,某个版本上出现的问题。。。但是我发现这个问题可以通过我下面的答案来解决…所以也许没人问只是因为它太简单而无法解决