Martin Muldoon
Martin Muldoon

Reputation: 3428

Issue with Container Views in XCode

I have a simple project with one view controller. I want to add two views and create a transition between the two.

I've read that I must add the two views to a container view. When I drag the container view to the Document Outline, It appears at the same level as the views. I can't get it to be higher in the hierarchy. What am I missing?

Thanks! Martin

Upvotes: 0

Views: 67

Answers (2)

Duncan C
Duncan C

Reputation: 131398

You need to explain what you want to do more clearly. You also need to be careful to use the right terms. Views and view controllers are different animals. Pretty much everything that appears on the iOS screen is a view: Buttons, labels, text fields, switches, etc are all views. The object that manages a whole screen-full of views is called a view CONTROLLER. Do not call view controllers views.

If you want a transition where 1 view controller gets fully replaced by another, you don't want container views. You want to use a navigation controller or maybe a modal segue. If you want a second view controller's view to appear inside your first view controller's views, then you want a container view.

If you just want to add additional views (text fields, image views, buttons, etc.) to your view controller then you just drag those objects onto your first view controller's scene in your storyboard.

In order to provide more help than that you're going to have to be clearer about what you are trying to do.

Upvotes: 0

André Slotta
André Slotta

Reputation: 14030

"container view" in this case does not mean the container view you can select from the object library (this one you need if you want to embed viewcontrollers in other viewcontrollers) but just a regular uiview. drag a regular uiview from the object library to your viewcontroller and put the views you want to animate into this container uiview.

Upvotes: 1

Related Questions