Lets say we have a custom UITableViewCell
So whenever I click custom button on cell.. it should expand to the some extent (you can say 40 height more…) and when i click again to the same custom button it should collapse to the previous height.
Developer’s please guide me.. how can I achieve this task
Implement heightForRowAtIndexPath to calculate the right height. Then in the code for your button, force the table to reevaluate each cell’s height with beginUpdates plus endUpdates:
Changes to the tableview cells’ heights will automatically be calculated with heightForRowAtIndexPath and the changes will be animated too.
In fact, instead of a button on your cell that does this, you might even just make selecting the cell do this in
didSelectRowAtIndexPath.