I'm making changes to a tableView using a beginUpdates/endUpdates block. Throughout the way I need to update a drop shadow so that it reflects the tableView's current composition.
I tried setting up KVO for the tableView's contentSize
but it's only called on endUpdates
, once the animation has finished. What I want is for it to be called every time contentSize
changes (even if it's by only a pixel). Is there any way to achieve this?
What about this?
[CATransaction begin];
[CATransaction setCompletionBlock:^{
// animation has finished
}];
[tableView beginUpdates];
// do some work
[tableView endUpdates];
[CATransaction commit];
Rudolf's method did not work for me as smooth as expected. In my case I was selecting a row on UITableView
using this, and Rudolf's method was causing the table to do two animations with a little freeze: the animation inside beginUpdates/endUpdates, a little freeze and the animation on the completion block.
[tableView selectRowAtIndexPath:indexPath
animated:YES
scrollPosition:scrollPosition];
that inspired me to create this code... and this is working seamlessly:
[UIView animateWithDuration:0.0 animations:^{
[tableView beginUpdates];
// do something to the table
[tableView endUpdates];
} completion:^(BOOL finished) {
// Code to run when table updates are complete.
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With