iOS Storyboard:ViewController外部和场景顶部的视图(在First Responder和Exit框之间) [英] iOS Storyboard: Views outside of the ViewController and on Top of the Scene (between First Responder and Exit boxes)

查看:627
本文介绍了iOS Storyboard:ViewController外部和场景顶部的视图(在First Responder和Exit框之间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解为什么你可以在故事板上的 UIViewController 之外放置 UIViews ,以及它的用例可能是。

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.

例如,在故事板上我可以添加 UIToolbar UIAcitivtyIndi​​cator UIProgressView UIViewController 之外。这是否意味着有一种方法可以引用 UIViewController 之外的 Views ,并可能以某种方式以编程方式显示它们或嵌入那些你会用 ContainerView

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!

当您添加视图控制器外部的对象时,它们会出现在Apple称为Scene Dock的内容中。 Apple为场景底座提供以下建议用法

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. 打开故事板。

  1. 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...


添加的视图是视图控制器的一部分。它将与其他视图一起实例化
。您可以将视图
附加到具有IBOutlet的视图控制器的属性。您可以将多个视图添加
到场景停靠点。

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.

(这些步骤最初是从此处 - 遗憾的是此页面似乎已被Apple删除在某些时候)。

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

这篇关于iOS Storyboard:ViewController外部和场景顶部的视图(在First Responder和Exit框之间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆