Frank R.
Frank R.

Reputation: 2380

Multiple view controllers in a single scene?

I've been a Mac programmer since 1993 and find it somewhat hard to get into the iOS frame of mind from time to time.

I've got an iPhone app that was designed for the iPhone 5 screen size and shows 3 different views with different functionalities depending on the orientation of the device (portrait and 2xlandscape).

Now on the iPad I want to separate the landscape screen into a left part controlled by one (existing) view controller and the right part by another (existing) view controller.

As part of trying to support split screen multi-tasking I want to support size classes but my views are in xib files at the moment.. and as far as I know size classes are bound to using storyboards, so I'm migrating to storyboards which seem very ill-structured for my purposes.

I can see that the idea is

1 window = 1 root controller

and

1 screen full = 1 scene = 1 view controller.

But what I need is two (or 3) view controller in a single scene.

I've had a look at UISplitView, which seems perfect only that the left view controller has to be a navigation controller, so not what I need. Perhaps a custom collection view controller is the answer?

I'm sure I'm missing something as I'm very much stuck in a Mac mindset and haven't used storyboards before.. what's the best way of re-using my existing view controllers in this scenario?

Any advice would be very much appreciated.

Upvotes: 3

Views: 4845

Answers (1)

bsarrazin
bsarrazin

Reputation: 4040

Take a look at this image:

There is a component in the object library called a container view. You can connect a new view controller via a segue to that container view. Basically, you can create a parent view controller whose sole purpose is to manage/move the views of other view controllers.

The parent view controller can have outlets to container views (which are simple UIView objects) and each container view can be its own view controller.

Hope this make sense, and sends you in the right direction.

Upvotes: 12

Related Questions