2

How can I add an UIView as a subview in a cells contentView when the user has tapped the cell, and remove the same UIView when the user taps that cell again?

I am trying to make a list of photos in a UITableView with expand/collapse button. The UIView that I want to add is the container of photo's information. Instagram accomplished it, but I cant figure out how to do it

Please help me guys :)

Thanks!!!

janusfidel
  • 8,036
  • 4
  • 30
  • 53

2 Answers2

0

I don't think you want to add a subview to the cell, but you want to add another cell to the already existing table. This way, you can achieve an "expand/collapse" feel to your table by using insertRowsAtIndexPaths:withRowAnimation:

Good luck!

Stavash
  • 14,244
  • 5
  • 52
  • 80
0

Adding and removing the views in the cell should be easy enough inside didSelectRow, but you may need to keep track of which rows are in what state (big or small) by recording that in a mutable array. The bigger issue you will have is adjusting a cell's height, but look here for that.

Community
  • 1
  • 1
ader
  • 5,403
  • 1
  • 21
  • 26