ReloadRowsAtIndexPaths without string animation

The problem with this code (inside func tableView (tableView: UITableView, commitEditingStyle editingStyle: 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)
}

is that both reloadRowsAtIndexPaths are animated, although indicated with RowAnimation: .None . What am I missing here?

+4
source share
1 answer

In iOSand it OS Xoften happens that you end up with an implicit animation for one reason or another (for example, the code is executed by another code that has already caused the animation).

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() , .

+8

Source: https://habr.com/ru/post/1609855/


All Articles