gpt4 book ai didi

uitableview - 没有行动画的 ReloadRowsAtIndexPaths

转载 作者:行者123 更新时间:2023-12-04 11:17:18 29 4
gpt4 key购买 nike

这段代码的问题(在 func tableView(tableView: UITableView, commitEditingStyleeditingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) 中)

tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)

if indexPath.row > 1{
tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: indexPath.row-1, inSection: 0)], withRowAnimation: .None)
}
if tDate[activeRow].count == 0{
tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: 0, inSection: 0)], withRowAnimation: .None)
}

是两者 reloadRowsAtIndexPaths 是动画的,虽然 withRowAnimation: .None 被指定。我在这里缺少什么?

最佳答案

iOS 中经常出现这种情况。和 OS X由于某种原因,您最终会得到一个隐式动画(例如,代码正在被其他已经触发动画的代码执行)。

使用 UITableView 控制动画可能特别困难。和 UICollectionView在我的经验中。您最好的选择可能是拨打 reloadRowsAtIndexPaths:withRowAnimation:传递给 UIView 的闭包的 performWithoutAnimations:方法:

UIView.performWithoutAnimation {
if indexPath.row > 1{
tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: indexPath.row-1, inSection: 0)], withRowAnimation: .None)
}
if tDate[activeRow].count == 0{
tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: 0, inSection: 0)], withRowAnimation: .None)
}
}

注意:拨打 tableView.beginUpdates() 也不错。和 tableView.endUpdates()在同时发生的多个更新之前和之后。

关于uitableview - 没有行动画的 ReloadRowsAtIndexPaths,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32896298/

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