I have a UITableViewCell
that expands and adds a label on click.
Logic:
I added a label in
cellForRowAtIndexPath
to the selected cell, and indidSelectRow...
I reloaded the tableView. InheightForRow...
the selected cell expands. Hope you get the picture.
In didSelectRow...
I have to reloadData, and not begin/end update. What I want to do is reloadData and have it animate. I can do like this:
[UIView transitionWithView: tableView
duration: 0.40f
options: UIViewAnimationOptionTransitionCrossDissolve
animations: ^(void)
{
[self.tableView reloadData];
}
completion: nil
}];
So that does a cross dissolve of the cells that is changing. What I want is UITableViewRowAnimationTop
, but apparently that is not possible in the transition options. Is there a way to reloadData
and use UITableViewRowAnimationTop
?
A much simpler solution that doesn't require CoreAnimation.
Swift 3:
UIView.transition(with: self.view,
duration: 0.15,
options: [.curveEaseInOut, .transitionCrossDissolve],
animations: {
self.tableView.reloadRows(at: self.tableView.indexPathsForVisibleRows!, with: .none)
}, completion: nil)