Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Storyboard: Views outside of the ViewController and on Top of the Scene (between First Responder and Exit boxes)

I am having a hard time understanding why you can put UIViews outside the UIViewController on the storyboard, and what the use case of it might be.

For instance, on the storyboard I can add UIToolbar, UIAcitivtyIndicator and UIProgressView that is outside of the UIViewController. Is this mean there is a way for you to reference those Views that are outside UIViewController and potentially display them somehow either programmatically or embed those like you would do with a ContainerView?

enter image description here Storyboard View

like image 672
DLee Avatar asked Jun 21 '16 20:06

DLee


1 Answers

Yes, it absolutely is possible to do what you're describing!

When you add objects that are outside the view controller, they appear in what Apple calls the "Scene Dock". Apple has the following suggested usage for the scene dock:

If a view is not part of the main view hierarchy — such as a pop-up menu — add the view to the scene dock. In a running app, the system adds and removes these kind of views from the view hierarchy when they are opened and closed.

The steps to make this work are below:

  1. Open the storyboard.

  2. Open the utilities area for the workspace window by clicking the utilities button in the toolbar.

  3. In the utilities area, select the Object library by clicking the Object Library button in the library bar.

  4. On the storyboard, select the scene to which you will add the extra view.

  5. Drag a view class object from the object library into the the scene dock.

And importantly...

The added view is a part of the view controller. It will be instantiated along with the rest of the views. You can attach the view to a property of the view controller that has an IBOutlet. You can add more than one view to the scene dock.

(These steps were originally copied from here - unfortunately this page seems to have been deleted by Apple at some point).

like image 157
shocking Avatar answered Sep 28 '22 04:09

shocking