epreston / PSTreeGraph

A tree graph view control for iPad applications. This is a port of the sample code from Max OS X to iOS (iPad).
http://epreston.github.io/PSTreeGraph/
259 stars 50 forks source link

Tip: toggle expand/collapse button with different icons #15

Open jolo2000 opened 12 years ago

jolo2000 commented 12 years ago

Hello,

this is just a little info. If you want that the expand/collapse button of the provided example app shows the according icon of the tree state (collapsed/expanded), then you can achieve this behaviour with this code snippet. Just connect the IBAction "toggleUIButtonImage" with the "Touch up inside" event in the IB of your xxxleaf.xib.

-(IBAction) toggleUIButtonImage:(id)sender{ if ([sender isSelected]) { [sender setImage:[UIImage imageNamed:@"TreeViewSubtreeCollapsedButton.png"] forState:UIControlStateNormal]; [sender setSelected:NO]; }else { [sender setImage:[UIImage imageNamed:@"TreeViewSubtreeExpandedButton.png"] forState:UIControlStateSelected]; [sender setSelected:YES];

}

}

HTH Johannes