How to create multi level views in NSTableView style?
I have got a project which has multiple levels. I do not find a proper way to start. The project mock ups are in hierarchical structure (tree like structure). It has almost 10 levels. So how to implement these levels in multiple table views where one action can open specific table view? Should I have to create different views for all levels? Or I can simply write data structure of my views in plist file (xml) and use that file for all levels. Please suggest me h开发者_Go百科ow to start. Thanks
If user interaction is required at each level & there is considerable information to be displayed to the user, then you should be going with nested UITableViews, where tapping on the row of one leads to the next one. You can have a look at the settings app for an example.
Yes, you will have to create a view for each level. However, 10 levels seems like a bit too much from the user experience point of view (Can you think of an existing app that has 10 levels?). You should give a thought to flattening your tree by combining a few levels together.
Use a CoreData-based "Navigation-based Application" from XCode.
Make an entity (e.g. TreeData) that has a one-to-many relationship with itself, called 'children'. Create an inverse relationship (one-to-one) on that, called 'parent'.
On the tableView:didSelectRowAtIndexPath: in the delegate you'd need to check to see if 'children' is set in your 'TreeData', if that is the case, then you'd need to push a new instance of the TableViewController you a currently in, with the children on the selected item as the dataSource.
This would allow you to keep traversing.
A plist would be the simplest way to give the general idea and get something working.
You could also achieve the same thing with a plist.
Something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Tree Root</key>
<array>
<dict>
<key>title</key>
<string>Google (No Children)</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>title</key>
<string>List of Web Sites</string>
<key>children</key>
<array>
<dict>
<key>title</key>
<string>digg</string>
<key>url</key>
<string>digg.com</string>
</dict>
<dict>
<key>title</key>
<string>iGoogle</string>
<key>url</key>
<string>www.google.com/ig</string>
</dict>
<dict>
<key>title</key>
<string>Stack Overflow</string>
<key>url</key>
<string>www.stackoverflow.com</string>
</dict>
</array>
</dict>
</array>
</dict>
</plist>
http://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TableView_iPhone/
精彩评论