Question

I'm learning how to use storyboards for iOS development and I can't seem to figure out how to manage multiple views on the same screen.

I want to be able to control multiple elements on the same screen, for example a UITableView with an UIImageView next to it.

This means I need 3 UIViewControllers, 1 for the UITableView, 1 for the UIImageView, and one for the main view. But as far as I can tell storyboards only allow for 1 controller per view hierarchy screen. Can anyone tell me what I'm missing?

Was it helpful?

Solution

View Controller Containment is the way to go. Have a look at Apple's documentation about it:

Creating Custom Container View Controllers

Container view controllers are a critical part of iOS app design. They allow you to decompose your app into smaller and simpler parts, each controlled by a view controller dedicated to that task. Containers allow these view controllers to work together to present a seamless interface.

You can use it in storyboards as well by using a container view.

enter image description here

Useful tutorial: Storyboards With Custom Container View Controllers

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