Reputation: 7207
table.beginUpdates()
array.removeLast()
table.deleteRowsAtIndexPaths([anIndexPath], withRowAnimation: UITableViewRowAnimation.None)
for object in container {
array.append(object)
}
array.append("New Object")
table.insertRowsAtIndexPaths([Set of IndexPaths]), withRowAnimation: UITableViewRowAnimation.Fade)
table.endUpdates()
I am using the above code. It works fine, but the only problem is the animation. After execution of above lines of code, table view scroll position is set to top. Not sure how. Thoughts are welcome.
Upvotes: 1
Views: 879
Reputation: 4187
I had this problem before setting this attribute : self.tableView.estimatedRowHeight
If you are using that, please try to add this method on your controller to prevent this kind of disappointment.
func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
Hope this can help you
Upvotes: 1