To solve soft impact animations:
Swift 3:
let indexPath = IndexPath(item: row, section: 0) tableView.reloadRows(at: [indexPath], with: .fade)
Swift 2.x:
let indexPath = NSIndexPath(forRow: row, inSection: 0) tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
This is another way to protect your application from crashes:
Swift 3:
let indexPath = IndexPath(item: row, section: 0) if let visibleIndexPaths = tableView.indexPathsForVisibleRows?.index(of: indexPath as IndexPath) { if visibleIndexPaths != NSNotFound { tableView.reloadRows(at: [indexPath], with: .fade) } }
Swift 2.x:
let indexPath = NSIndexPath(forRow: row, inSection: 0) if let visibleIndexPaths = tableView.indexPathsForVisibleRows?.indexOf(indexPath) { if visibleIndexPaths != NSNotFound { tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) } }
Alessandro Ornano Apr 18 '16 at 7:22 2016-04-18 07:22
source share