|
23 | 23 | @implementation AMBTableViewController |
24 | 24 | { |
25 | 25 | NSMutableArray * _mutableSections; |
| 26 | + BOOL _useCustomAnimations; |
| 27 | + UITableViewRowAnimation _customReloadAnimation; |
| 28 | + UITableViewRowAnimation _customInsertAnimation; |
| 29 | + UITableViewRowAnimation _customRemoveAnimation; |
26 | 30 | } |
27 | 31 |
|
28 | 32 | @dynamic sections; |
@@ -126,6 +130,46 @@ - (void)replaceSectionAtIndex:(NSUInteger)index |
126 | 130 | [section reload]; |
127 | 131 | } |
128 | 132 |
|
| 133 | +#pragma mark - Configuring animations |
| 134 | + |
| 135 | +- (UITableViewRowAnimation)reloadAnimation |
| 136 | +{ |
| 137 | + return _useCustomAnimations ? _customReloadAnimation : _reloadAnimation; |
| 138 | +} |
| 139 | + |
| 140 | +- (UITableViewRowAnimation)insertAnimation |
| 141 | +{ |
| 142 | + return _useCustomAnimations ? _customInsertAnimation : _insertAnimation; |
| 143 | +} |
| 144 | + |
| 145 | +- (UITableViewRowAnimation)removeAnimation |
| 146 | +{ |
| 147 | + return _useCustomAnimations ? _customRemoveAnimation : _removeAnimation; |
| 148 | +} |
| 149 | + |
| 150 | +- (void)applyChanges:(void (^)(void))changes |
| 151 | + withAnimation:(UITableViewRowAnimation)animation |
| 152 | +{ |
| 153 | + [self applyChanges:changes |
| 154 | + withReloadAnimation:animation |
| 155 | + insertAnimation:animation |
| 156 | + removeAnimation:animation]; |
| 157 | +} |
| 158 | + |
| 159 | +- (void)applyChanges:(void (^)(void))changes |
| 160 | + withReloadAnimation:(UITableViewRowAnimation)reloadAnimation |
| 161 | + insertAnimation:(UITableViewRowAnimation)insertAnimation |
| 162 | + removeAnimation:(UITableViewRowAnimation)removeAnimation |
| 163 | +{ |
| 164 | + _useCustomAnimations = YES; |
| 165 | + _customReloadAnimation = reloadAnimation; |
| 166 | + _customInsertAnimation = insertAnimation; |
| 167 | + _customRemoveAnimation = removeAnimation; |
| 168 | + |
| 169 | + changes(); |
| 170 | + |
| 171 | + _useCustomAnimations = NO; |
| 172 | +} |
129 | 173 |
|
130 | 174 | #pragma mark - Convenience methods |
131 | 175 |
|
|
0 commit comments