In fact, there DOES seems to be a way to do this (although not as straightforward as it should be!).
While there is no direct access to some callback, it seems that the animation of the UITableView occurs within CAAnimation . Therefore, easy access to completionBlock CAAnimation seems to give you what you want.
Here, as I got 2 animations for binding in my subclass of UITableView :
#pragma mark - Section expanding/collapsing - (void)toggleSection:(NSInteger)index { int expandedSection = [self ExpandedSection]; if (expandedSection != NO_EXPANDED_SECTIONS_INDEX) { [self beginUpdates]; [self collapseSection:@(expandedSection)]; [CATransaction setCompletionBlock:^{ if (expandedSection != index) { [self beginUpdates]; [self expandSection:@(index)]; [self endUpdates]; } }]; [self endUpdates]; } else { [self expandSection:@(index)]; } }
The code in the collapseSection: and expandingSection: methods simply adds / removes the subsections that need to be expanded or expanded. The key point here is that when using this code, I can finally collapse one of the THEN sub-sections to expand the next subsection. Previously, both animations took place simultaneously, which was visually unattractive.
Hope this helps! I tried it for a long time, hitting my head against the wall until I found it.
It is written against iOS 6.0. I also really hope that some future version will make this workaround / hack obsolete!
source share