Lucy Jeong
Lucy Jeong

Reputation: 337

How to add view beside tableviewcell with Swift?

I'd like to add view beside tableviewcell when user click table view cell.

before user click

---cell1---
---cell2---

after user clicked

---cell1---
---detailview---
---cell2---
How to do that?

Upvotes: 0

Views: 167

Answers (2)

user4034301
user4034301

Reputation:

If you are looking for something like another view appearing below the tapped cell and not an expanding tapped cell,you can insert a tableview cell just after the tapped cell.Use insertRowsAtIndexPaths and insert the cell.You can create this cell as a custom cell.

Upvotes: 2

childrenOurFuture
childrenOurFuture

Reputation: 1987

There is 2 options to do that:
- To make detailView as another cell, just insert below the cell user clicks
- Cell add the detailView initially. And make a switch to show it or hide it.Just because cell in table view is reused, we should not add subview in a cell already in table view, which will cause some problem in reusing.

Upvotes: 0

Related Questions