I have a UITableView
. I want to add a cell
to the beginning of the tableView
with animation. I tried the following:
let indexPath = NSIndexPath(forRow: 0, inSection: 0)
tableView.reloadRowsAtIndexPaths(indexPath, withRowAnimation: UITableViewRowAnimation.Automatic)
But I get the following error:
Cannot invoke
'reloadRowsAtIndexPaths'
with an argument list of type'(NSIndexPath!, withRowAnimation: UITableViewRowAnimation)'
(When I just do tableView.reloadData()
it works fine.)
What am I doing wrong, and how can I fix it?
You get the error, because reloadRowsAtIndexPaths
expects an array of index paths, not a single index path. However reloadRowsAtIndexPaths
wouldn't add a cell, but just reload the cells at the specified index paths.
Instead you should use insertRowsAtIndexPaths
to add your cell.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments