UITableView row animation duration and completion callback
Nowadays if you want to do this there is new function starting from iOS 11:
- (void)performBatchUpdates:(void (^)(void))updates
completion:(void (^)(BOOL finished))completion;
In updates closures you place the same code as in beginUpdates()/endUpdates section. And the completion is executed after all animations.
How do I wait until a UITableView built-in animation is complete?
Thank you Iducool for pointing me to the other question.
This worked...
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight];
}];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft];
[CATransaction commit];
I didn't seem to require UITableView
's beginUpdates
and endUpdates
.
UITableView, how to catch the end of animation?
The animation is controlled by a instance of class CAAnimation
. This class supports a method - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
which will be delivered to the delegate of this instance. This information is typically used to get informed on the completion.
In regard to your special request i would have a look at the UIView
Class reference. There are several tasks that deal with animations of that view - which is the base class of UITableView
. Therefore anything that is valid for UIView
should have effect on the table view.
How to detect when animation completes on UITableViewCell deselect row
[CATransaction begin];
[tableView beginUpdates];
[CATransaction setCompletionBlock: ^{
NSLog(@"Completion code here");
}];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[tableView endUpdates];
[CATransaction commit];
Related Topics
How to Calculate Uilabel Width Based on Text Length
Framework Not Found Googletoolboxformac
How to Animate the Change of Image in an Uiimageview
Use Multiple Font Colors in a Single Label
iPad Remembering Camera Permissions After Delete-How to Clear
Given a View, How to Get Its Viewcontroller
Swift 3 - How to Verify Class Type of Object
Place Images Along a Bezier Path
Silent Push Notification in iOS 7 Does Not Work
What's the Best Way to Find the User's Documents Directory on an Iphone
Custom Installed Font Not Displayed Correctly in Uilabel
Logging Data on Device and Retrieving the Log
How to Use Avcapturephotooutput
How to Access Own Window Within Swiftui View
Determine If the Access to Photo Library Is Set or Not - PHPhotolibrary
Creating a Shadow for a Uiimageview That Has Rounded Corners