Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Views in Same Container View Using Storyboard

I have a viewcontroller with a background image and title header. This view remains same most of the time. And I have different child views that i will be showing and hiding inside this viewcontroller.

How can i achieve this using storyboard?

  1. Do i have to create separate xibs for each child views?
  2. Or do i create individual views inside the same view controller and hide and show them as needed?

Or is there any other elegant solution?

Thanks.

like image 804
Kiran Thapa Avatar asked Apr 01 '26 18:04

Kiran Thapa


2 Answers

Please have a look at this tutorial: How to use a 'Container View' in iOS?

The overall idea is shown in the image.

enter image description here

like image 176
Amit Thakur Avatar answered Apr 04 '26 08:04

Amit Thakur


It will be much easy to design your UI if you use container views.

Add the container view for all your child views. Create properties for all the child container views in your main View Controller. Design the child views with in the container view controller. Apply business logic in your main view controller to show and hide the child views accordingly.

like image 42
Alex Andrews Avatar answered Apr 04 '26 07:04

Alex Andrews