Skip to content

Instantly share code, notes, and snippets.

@Groxx
Created July 31, 2012 22:26
Show Gist options
  • Save Groxx/3221207 to your computer and use it in GitHub Desktop.
Save Groxx/3221207 to your computer and use it in GitHub Desktop.
Table updates w/w/o animations
@interface UITableView (UpdateBlock)
- (void)updates:(void(^)())updates;
- (void)updatesWithoutAnimations:(void(^)())updates;
@end
@implementation
- (void)updates:(void(^)())updates
{
[self beginUpdates];
updates();
[self endUpdates];
}
- (void)updatesWithoutAnimations:(void(^)())updates
{
BOOL wasAnimated = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[self updates:updates];
[UIView setAnimationsEnabled:wasAnimated];
}
@end
@interface UITableView (UpdateBlock)
- (void) updates:(void(^)())updates;
- (void) updatesWithoutAnimations:(void(^)())updates;
@end
@implementation UITableView
- (void) updates:(void(^)())updates
{
[self beginUpdates];
updates();
[self endUpdates];
}
- (void) updatesWithoutAnimations:(void(^)())updates
{
BOOL wasAnimated = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[self updates:updates];
[UIView setAnimationsEnabled:wasAnimated];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment