Question

working on my first iPad project and after many false starts I have a basic interface that I am happy with that consists of a Split View Controller with a 4-tab Tab Bar at the bottom of the Root/Popover.

I have 4 different View Controllers for each of the 4 tabs. Three of these contain tables, the fourth contains my settings sliders & switches. All this works fine in portrait or landscape.

The challenge I'm facing is how to drive the Detail View from these various tabs. I don't necessarily need multiple Detail Views since all 3 tables will be referencing the same data, just sorted differently. So they could potentially all connect to the same Detail View.

I haven't found any other examples of Tab bars being used like this, but it seems like the perfect solution for my app.

How do I establish a connection so that when I select a table cell, the detailItem info gets displayed in the Detail View? Tab bar was added to the Root View in IB. Should I be adding it programmatically instead?

Does anyone have an example project where you've gotten this to work?

Thanks!

Was it helpful?

Solution

Don't get too caught up in the 'tabbar' piece of this. Consider how a simpler app would work: if you select a cell in the RootViewController, how would you notify the DetailViewController?

It won't be automatic. Most likely, you will have a dedicated connection from the RootViewController to the DetailViewController - and you will invoke some method on the DetailViewController from the RootViewController in something like the

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

method in the RootViewController. Indeed, this is how the template UISplitView iPad app is setup. There is an IBOutlet connection from the RootViewController to the DetailViewController.

As long as you manage the memory correctly (retain, release) - there should be no problem if each of your (root) view controllers (in the tab view) have a connection to the single DetailViewController. To keep the tab'd controllers from stepping on each other, you may wish to centralize the logic into a 'middleman' class. Maybe you want to clean something up just before ViewControllerB sorts the details that ViewControllerA just sorted ...

That part is up to you. Just note that there is no backend black magic going on such that a DetailViewController is automatically updated to show something based on a cell selected in any RootViewController.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top