0

I want to implement accordian in only one of my UITableView rows (second row maybe) and I want to implement this without using any custom class or custom cell class. Clicking on the accordian row 'n' rows should be added under that row and I also want to track that rows didSelectRow() delegate method for that row and also for other rows independently. What is the best way to do it any help is appreciated.

possible duplicate

Community
  • 1
  • 1
Satheesh
  • 10,998
  • 6
  • 50
  • 93

1 Answers1

2

I did this once with a Plain UITableView, without any custom cells, with the help of the method tableView:viewForHeaderInSection:. I used this method to design the headers of each section as a button to collapse/expand its rows.

You should maintain an array of booleans that indicates whether a specific section is expanded, i.e. its rows are visible. This array should start with all values false. Then when a section header is clicked, you should change its value in the array to true.

The method tableView:numberOfRowsInSection will return 0 if that section is collapsed or the number of rows in that section if it's expanded.

Finally you should use the reloadSections:withRowAnimation: method to animate the expanding/collapsing.

Eli Ganem
  • 1,479
  • 1
  • 13
  • 26