Syed Uzair Ahmed
Syed Uzair Ahmed

Reputation: 145

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.

Upvotes: 2

Views: 1068

Answers (1)

Diksha
Diksha

Reputation: 449

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

Upvotes: 1

Related Questions