anisha
anisha

Reputation: 61

how to hide and show the elements in tableviewcell based on cell selection

I have been trying to hide and show UIView which is in tableviewcell based on cell selection.when the cell is selected, then the view should be visible and if the cell index is changed then the view should be invisible in the last selected cell and should be visible in current selected cell.If any one helps me would be great,Thanks in advance.

Upvotes: 0

Views: 69

Answers (2)

Najeeb ur Rehman
Najeeb ur Rehman

Reputation: 413

Implement the UITableView Delegate method

tableView:didSelectRowAtIndexPath:

And in this method store the selected row in a variable and reloads your tableview. Then in

tableView:cellForRowAtIndexPath:

show/hide the view for the row based on the selected row variable.

Upvotes: 1

Friend
Friend

Reputation: 125

Put the Views in Tableviewcell inside a stackView & then on cell selection in didselectRow you can simply hide or unhide views.

Upvotes: 0

Related Questions