Proper way to present nested tree

63 views Asked by At

I have tree like this:

Root
-CountryA
    -RegionA
        -producerA
    -RegionB
        -ProducerB
        -ProducerC
    -RegionC
        -ProducerD
-CountryB
.
.
Several countries with the same pattern

And I have to reach one producer.

At first I've used a UITableViewController for each level but in time I saw that this is not the best approach. Now I'm thinking about one UTableViewController with expandable cells.

How you handle similar problem?

1

There are 1 answers

1
Sergii Martynenko Jr On BEST ANSWER

I would suggest inserting new cells under chosen one.

You have

-CountryA
-CountryB
-CountryC

User selects CountryB. Then, in tableView:didSelectRowAtIndexPath: use method insertRowsAtIndexPaths:withRowAnimation: with index paths section 0 and rows 2-(number of regions in CountryB).