1

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.

4
  • Why can't you use UISplitViewController? Jan 4, 2014 at 6:00
  • 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? Jan 4, 2014 at 6:15
  • You can have two UINavigationControllers as Master and Detail in UISplitViewController Jan 4, 2014 at 6:16
  • Also, you are correct that according to Apple, the UISplitViewController should be your main Skeleton Controller of your app Jan 4, 2014 at 6:17

2 Answers 2

1

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

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.

1
  • Thanks for your answer. The issue I'm having with UISplitViewController is that PPAircraftViewController (the top-level wrapper in this case) is pushed to from a parent navigation controller (the above scenario is one of many master/detail constructs; it has siblings). UISplitViewController cannot be a child of a navigation controller. Jan 4, 2014 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.