gpt4 book ai didi

ios - UITableViewCell 删除滑动动画丑陋

转载 作者:可可西里 更新时间:2023-11-01 00:55:56 24 4
gpt4 key购买 nike

我有以下问题。当我使用“滑动删除”从我的 UITableView 中删除 UITableViewCells 时,我看到了 UITableView 的丑陋行为。无论我在 deleteRows 方法中选择哪种动画,所有删除都会导致相同的奇怪行为。

这是我删除单元格的代码

func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
print("Deleted")

self.tvItems.beginUpdates()

if(indexPath.section == 0){
Shoppingcart.shared.removeItemForId(ident: indexPath.row)
}else if (indexPath.section == 1){
Shoppingcart.shared.serviceContent.remove(at: indexPath.row)
}

if let parent = self.parent as? CollectionViewController{
parent.collectionView?.reloadData()
}
self.tvItems.deleteRows(at: [indexPath], with: .fade)

self.tvItems.endUpdates()

}
}

这是损坏动画的图像:

See the broken animation here

最佳答案

我找到了解决问题的方法。 tableviewcell 高度估计设置为自动。我确实将高度设置为与行高相同,并且损坏的动画消失了。

splinter 动画的设置:

Wrong

工作动画的设置:

Right

关于ios - UITableViewCell 删除滑动动画丑陋,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48437290/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com