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
?
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:
Open the storyboard.
Open the utilities area for the workspace window by clicking the utilities button in the toolbar.
In the utilities area, select the Object library by clicking the Object Library button in the library bar.
On the storyboard, select the scene to which you will add the extra view.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With