Reputation: 14060
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:
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 IBOutlet
s?
Xcode 5, targeting iOS 6 & 7, UISplitViewController not an option since all of this is embedded within a parent navigation controller.
Upvotes: 1
Views: 1026
Reputation: 14060
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!
Upvotes: 1
Reputation: 121
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.
Upvotes: 0