iPad Navigation between different subviews

I'm an experienced programmer, but fairly new to iOS/ObjC. I need to add a feature to an existing iPad app, and I'm not sure how to go about it.

The app has a view (let's call it InfoView) with several subcomponents, one of which is a tableview (TableView), and two of which are buttons (ButtonA and ButtonB) (plus other stuff that's irrelevant to this problem).

When ButtonB is pressed, TableView needs to be replaced by some other view (let's call it DetailViewA) with various items on. (ButtonA takes us back to TableView - these buttons act like pseudo tab buttons) When one of the items in DetailViewA is selected, DetailViewA needs to be replaced by DetailViewB. When DetailViewB is closed, detailViewA should re-appear.

I believe I can do the toggling between TableView and DetailViewA by simply hiding the appropriate one when ButtonA/ButtonB is pressed, but I don't know how to nicely deal with drilling down into DetailViewB and back up again (preferably with some sliding animation) - I thought that perhaps I could maybe do this with a UINavigationController, but after some research I still can't see how I'd embed a UINavigationController inside a subview.

A picture tells a thousand words, so here's my rough sketch of what I'm talking about:

+--------------------------------------------------------------------------+
|           InfoView                 |                TopView              |
|     [ButtonA]      [ButtonB]       |                                     |
|    (show table)  (show detail)     |                                     |
| ---------------------------------- |                                     |
|                                    |                                     |
|   this area contains TableView     |                                     |
|                                    |                                     |
|   when ButtonB is touched this     |           other stuff here          |
|   needs to display DetailViewA     |                                     |
|   with the ability to drill down   |                                     |
|   deeper to DetailViewB  (and      |                                     |
|      maybe deeper)                 |                                     |

Or hierarchically: ( [ ] indicating uncertainty / unimplemented)

TopView
\ InfoView
   \ ButtonA
   | ButtonB
   | TableView           - Shown when ButtonA pressed
   | [ MoreInfoView? ]   - Shown when ButtonB pressed
      \ [ DetailViewA ]
      | [ DetailViewB ]

What's the best way to implement this functionality?

Answers


You can embed a navigation controller inside a view using child view controllers. Set up your navigation controller with a controller for DetailViewA as the root view controller, then call this code to embed the navigation controller:

[self addChildViewController:self.detailNavigationController]; 
self.detailNavigationController.view.frame = frameOfTableView;
[self.view addSubview:self.detailNavigationController.view];
[self.detailNavigationController didMoveToParentViewController:self];  

You would hide the original table view when the button was pressed and show the navigation controller. The navigation controller would then handle the "drilling down" between detail views.

Note that you will need view controllers for DetailViewA and DetailViewB, not just views.

Hope this helps!


Need Your Help

Access to hyperlink in a pdf(iPhone)?

iphone

I am working on a small app, which can open a pdf. My question is, if it is possible to access a hyperlink from a pdf? Because when am trying to click on hyperlink nothing is happening and it's not

BigCommerce API - Can't create a new customer

php bigcommerce

Checked out similar questions on Stackoverflow but, being a newbie to BC, still having real trouble with this one. Trying to create a new customer using Bigcommerce API (PHP).