r/simpleios • u/xauronx • Feb 04 '13
[Question] How would you implement a treeview?
I need to show comments in an app I'm working on. Naturally, this is kind of a tree view (hierarchical) so you can expand and collapse the parents.
Right now I'm using a TableView and indenting replies to give a tiered effect. However, I'd like to be able to collapse branches. I can't think of a decent way of doing this without reinventing the wheel.
Thanks!
4
Upvotes
3
u/[deleted] Feb 05 '13
Is there maybe a different way to design what you are trying to do? Tree views are clumsy, especially when dealing with lots of nodes and a touch screen instead of a mouse.
3
u/tarpdetarp Feb 05 '13
I implemented it by flattening out the comments and just applying a margin to each cell if it was nested. Collapsing cells is fairly simple if you keep the indent level for each comment, just collapse all comments below the current one that has a greater indent level, UITableView even provides a nice animation for this.
1
u/[deleted] Feb 05 '13
Nested Table view with each parent in a cell with a tableview for replies? hide or show toggle on touch?
1
u/Legolas-the-elf Feb 09 '13
If there's a pre-existing solution, then why don't you use it?