Delegate callbacks did/willCollapseRowForItem
When using either:
[treeView expandRowForItem:dataObject];
[treeView collapseRowForItem:dataObject];
the appropriate delegates are not called:
- (void)treeView:(RATreeView *)treeView willCollapseRowForItem:(id)item
- (void)treeView:(RATreeView *)treeView willExpandRowForItem:(id)item
- (void)treeView:(RATreeView *)treeView didCollapseRowForItem:(id)item
- (void)treeView:(RATreeView *)treeView didExpandRowForItem:(id)item
This is needed if you don't want to expand/collapse on cell selection, but instead use an accessory button to do so. Is this by design, and if so, is there a workaround?
Yes, it is by design. You don't need information from delegate about row being expanded/collapsed as you are the one who starts cell action by calling expandRowForItem or collapseRowForItem method.
Ok, so how can you know when the expand/collapse animation is complete?
Ok, I see. I think it is not possible to be informed about the end of the animation using current API.
Why do you need this information? Maybe there is another way to get the result you want to achieve.
I needed it because I wanted to use a button instead of the selected row for expanding/collapsing children. I ended up writing my own tree implementation for this.
Are there any updates on this? I think it's important to know when the tree view has fully expanded in a scenario where the superview of the tree view needs to respond to the growth in height.
I modified expandRowForItem:withRowAnimation method to call delegates in RATreeView.m as follows
- (void)expandRowForItem:(id)item withRowAnimation:(RATreeViewRowAnimation)animation
{
NSInteger index = [self.treeNodeCollectionController indexForItem:item];
RATreeNode *treeNode = [self.treeNodeCollectionController treeNodeForIndex:index];
if (treeNode.expanded) {
return;
}
[self.delegate treeView:self willExpandRowForItem:item treeNodeInfo:treeNode.treeNodeInfo]; // < - -
[self expandCellForTreeNode:treeNode withRowAnimation:animation];
[self.delegate treeView:self didExpandRowForItem:item treeNodeInfo:treeNode.treeNodeInfo]; //<- -
}
This is working fine for me. Same can be done for collapse.