Is there a way to either specify the duration for UITableView row animations, or to get a callback when the animation completes?
What I would like to do is flash the scroll indicators after the animation completes. Doing the flash before then doesn't do anything. So far the workaround I have is to delay half a second (that seems to be the default animation duration), i.e.:
[self.tableView insertRowsAtIndexPaths:newRows
withRowAnimation:UITableViewRowAnimationFade];
[self.tableView performSelector:@selector(flashScrollIndicators)
withObject:nil
afterDelay:0.5];
Expanding on karwag's fine answer, note that on iOS 7, surrounding the CATransaction with a UIView Animation offers control of the table animation duration.
The UIView animation's duration has no effect on iOS 6. Perhaps iOS 7 table animations are implemented differently, at the UIView level.
Shortening Brent's fine answer, for at least iOS 7 you can wrap this all tersely in a [UIView animateWithDuration:delay:options:animations:completion:] call:
though, I can't seem to override the default animation curve from anything other than EaseInOut.
Override tableView -insertRowsAtIndexPaths: and implement the custom insertion/(or the deletion with its own method) animation you want. Didn't try it my self though.
Just came across this. Here's how to do it:
Objective-C
Swift
Here's a Swift version of karwag's answer
You could try to wrap the insertRowsAtIndexPath in a
transaction, then do the flash afterwards.