草庐IT

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

coder 2023-07-28 原文

我很难理解为什么可以将 UIViews 放在 Storyboard上的 UIViewController 之外,以及它的用例可能是什么。

例如,在 Storyboard上,我可以在 UIViewController 之外添加 UIToolbarUIAcitivtyIndi​​catorUIProgressView >。这是否意味着您有一种方法可以引用 UIViewController 之外的那些 Views 并可能以某种方式以编程方式显示它们或像使用 那样嵌入它们容器 View ?

最佳答案

是的,完全有可能做到您所描述的!

当您添加 View Controller 外部的对象时,它们会出现在 Apple 所谓的“场景停靠栏”中。 Apple 有以下 suggested usage对于场景码头:

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.

完成这项工作的步骤如下:

  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.

重要的是......

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.

(这些步骤最初是从 here 复制的 - 不幸的是,此页面似乎已被 Apple 删除)。

关于iOS Storyboard : Views outside of the ViewController and on Top of the Scene (between First Responder and Exit boxes),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37954223/

有关iOS Storyboard : Views outside of the ViewController and on Top of the Scene (between First Responder and Exit boxes)的更多相关文章

随机推荐