Mafioso Mafioso - 1 year ago 285
iOS Question

Expand and Collapse first row on button click Objective - C

I want to expand and collapse the first row on button click. Button is in navigation bar. Can anybody help me in this.
Through Code.

Answer Source

When You click on the button,just check the state on 1st row of a table if it is collapsed then reload 1 row using reloadRowAtIndexpath method and change the size of the cell in size for row at indexpath.Same Procedure while collapsing.

For Expand and Collapse :-

-(IBAction) aButtonTapped:(id)sender {

[[self tableView] beginUpdates];
[[self tableView] reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForItem: 0 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
[[self tableView] endUpdates]; }

Change the height in heightForRowAtIndexpath and apply check to see if the row is already expanded or not

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download