0

I'm looking for the generally accepted/best solution to this problem.

Problem

I have a UITableViewController populated with UITableViewCell objects that represent FooModel objects. When a user taps on a row, I want to add one or more additional cells below that cell with additional controls. So the question is: what is the best way to manage model-cells and control-cells in the table? Keeping an array of UITableViewCell objects defeats the purpose of dequeueReusableCellWithIdentifier: (doesn't it?) because it must preserve all of the views in the whole table. So what should be in the array used to tell the data source what cells go at what indexes? Or is there a better solution?

mockup

Jonathan Swinney
  • 1,054
  • 9
  • 29

2 Answers2

1

You can make your life REALLY easy, if you just expand the cell and add subviews to expose functionality underneath.

That way, you can keep your order in the data source and use the normal navigation methods.

If you need an example, let me know!

Nick Esposito
  • 395
  • 2
  • 6
0

Create liaison objects that maintain the minimum amount of data for satisfying the UITableViewDataSource protocol, like cell height and reference the model object whatever information needed to create the control cells. See this class diagram:

class diagram

Jonathan Swinney
  • 1,054
  • 9
  • 29