1
votes

I have an iPhone storyboard with a UITableView that segues to a detail view using a navigation controller. I'm trying to reuse my classes in the iPad version of the same app inside a master-detail UI.

Here's how my storyboards look to visualize what I'm doing:

iPhone and iPad storyboards

I want to reuse as much code as possible, and so far I've been successful in reusing my PPAircraftViewController class with its aircraftTableView.

Question: Since the iPad app already uses PPAircraftViewController to hold the table and detail views, how can I reuse my PPAircraftDetailViewController class with all its code and IBOutlets?


Xcode 5, targeting iOS 6 & 7, UISplitViewController not an option since all of this is embedded within a parent navigation controller.

2
Why can't you use UISplitViewController?Bilal Saifudeen
The above screens are part of a navigation controller, and as I understand UISplitViewController, it has to be at the root of an application. I can't push to it. Am I mistaken?Clifton Labrum
You can have two UINavigationControllers as Master and Detail in UISplitViewControllerBilal Saifudeen
Also, you are correct that according to Apple, the UISplitViewController should be your main Skeleton Controller of your appBilal Saifudeen

2 Answers

1
votes

I finally found what I was looking for. I can't believe it took me so long to remember it, but the perfect solution for this scenario is a UIContainerView.

It lets me embed the PPAircraftDetailViewController inside its containing view controller as pictured below.

Thanks, everyone!

UIContainerView

0
votes

On the iPhone your PPAircraftDetailViewController gets pushed on the navigation stack by the PPAircraftViewController.

That makes either the one or the other visible to the user.

On the iPad, Apple provides a mechanism to show a MasterView and a DetailView side by side in a UISplitViewController.

In that case, the MasterViewController does not "push" the DetailViewController, but activates it through IBOutlets and Delegation.

You can have your PPAircraftViewController as (part of) the MasterViewController and your PPAircraftDetailViewer as (part of) the DetailViewController.

It will require some tweaking, but will also save you a lot of effort as sizing and rotating will be done by the SplitViewController.