Created
July 31, 2012 22:26
-
-
Save Groxx/3221207 to your computer and use it in GitHub Desktop.
Table updates w/w/o animations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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