How simulate a navigationController/UITableView DrillDown in a smaller area of the iPad?
I have a 2-deep menu (UITableView) that is a subview in the main one on the iPad. So, this is not a controller, is a regular UITableView.
However, I want to provide the same visual feedback as with navigation controller, so when a item in the first-level of the table is selected, get push the second and the ability to go back.
This i开发者_开发问答s not in a splitview, and for this UI, a splitview is not the answer. Think as if the table is a box inside a bigger one, with other boxs around.
I was able to achieve this by creating a master view controller that held a navigation controller and any of the sub-layer views. I followed the same general principle as found in Apple's DrillDownSave sample except I skipped the Window object and the AppDelegate object in the xib file. I used a UIView instead since I was using a UIViewController to manage everything.
All I had to do after that was create an instance of the master view controller in whatever view I wanted to place it in and set its frame to wherever I wanted it to show up in that view. One interesting issue I ran into was that the navigation controller wanted to span the width of the screen even if its parent view was set smaller. All I had to do was set its width in its frame at the same time I set its master view's frame and everything worked out well.
It's a lot of code to put here but the basic layout goes:
- Some View Controller
- Master View Controller for the navigation item (set as a property of the "some" view controller and instantiated/positioned/added as a subview in its viewDidLoad)
- UINavigationController (in the xib, like the Apple example)
- First level view controller with UITable
- Second level view controller with UITable
- Third level view controller with UITable
- UINavigationController (in the xib, like the Apple example)
- Placeholder view in the xib to line up navigation item master a little easier
- Master View Controller for the navigation item (set as a property of the "some" view controller and instantiated/positioned/added as a subview in its viewDidLoad)
*note - I did not use a leaf view like the Apple example because I didn't need it for my purposes
I don't know if I explained it very well so if you need further clarification let me know. Hope this helps!
精彩评论