Hide / Unhide View in self sizing UITableViewCell

361 Views Asked by At

I have a self sizing tableview cell which contains 3 cells as shown below

|----------------------------------|

Button1 ________ Label

(Hidden View)

|----------------------------------|

Button2 ________ Label

|----------------------------------|

Button3 ________ Label

|----------------------------------|

When I tap on Button 1, Cell 1 should expand and Hidden View should be visible and Cell 1 should expand based on hidden view height. Also when Hidden view is hidden, Cell 1 should shrink accordingly. How to achieve this.

Note: All 3 cell button state should change when Hidden view is hidden or shown. Any good solution to achieve this?

1

There are 1 best solutions below

2
On

Define one variable e.g. var isButtonOneTapped = Bool()

when you tap on that button set it true. i.e. isButtonOneTapped = true. and reload table.

and set your tableview's delegates method according to that variable.

for exa: in heightForRow method

{ if(isButtonOnetapped)

{

   return someValue

}

else

{

return otherValue

   }

}