Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nesting view controllers inside a storyboard

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?

like image 658
user1177007 Avatar asked Jan 11 '23 02:01

user1177007


1 Answers

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

like image 95
Rafa de King Avatar answered Jan 24 '23 23:01

Rafa de King