(see this answer. Claims to Tapas Pal for writing the original answer. I just modified it to better fit your question.)
BOOL, , . (, NSInteger), .
BOOL shouldCellBeExpanded = NO;
NSInteger indexOfExpandedCell = -1;
-tableView:cellForRowAtIndexPath: , . , , , . , - , if.
[[cell aButton] setTag:[indexPath row]];
if(shouldCellBeExpanded && [indexPath row] == indexOfExpandedCell)
{
}
IBAction. , UITableView , . . UITableView, . , .
-(IBAction) aButtonTapped:(id)sender
{
UIButton *aButton = (UIButton *)sender;
indexOfExpandedCell = [aButton tag];
shouldCellBeExpanded = YES;
[[self tableView] beginUpdates];
[[self tableView] reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForItem: indexOfExpandedCell inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
[[self tableView] endUpdates];
}
, -tableView:heightForRowAtIndexPath::
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(shouldCellBeExpanded && [indexPath row] == indexOfExpandedCell)
return 200.0f;
else
return 100.0f;
}
, , , , , . , - . , .