如何连接Xcode Storyboard的“模拟指标”工具栏到实际的IBOutlet UIToolbar? [英] How to connect Xcode Storyboard's "Simulated Metrics" toolbar to an actual IBOutlet UIToolbar?

查看:248
本文介绍了如何连接Xcode Storyboard的“模拟指标”工具栏到实际的IBOutlet UIToolbar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试通过Xcode Storyboard设计UIToolbar附件视图时遇到问题。

I'm hitting issues when attempting to design a UIToolbar Accessory View via an Xcode Storyboard.

当我将UIToolbar对象拖到View Controller的上边距时,该项目被添加到左侧窗格,我可以将它连接到我的班级的IBOutlets。当我运行应用程序时,它显示正确。

When I drag a UIToolbar object to the top margin of my View Controller, the item is added to the left pane and I am able to connect it to my class's IBOutlets. It appears correctly when I run the app.

但是,故事板上任何位置的工具栏都不可见。因此,我首先失去了使用Interface Builder的视觉编辑优势。条形按钮项目仅在左侧边栏中可见。

However, the toolbar is not visible anywhere on the storyboard. I thus lose the visual editing benefits of using Interface Builder in the first place. The bar button items are only visible in the left sidebar.

我似乎无法通过使用View Controller的模拟指标来查看IB画布中的视图。现在我可以在故事板中看到一个工具栏。

I have seemingly gotten around being unable to see the views in the IB canvas by using the View Controller's "Simulated Metrics". Now I can see a Toolbar in the Storyboard.


  • 属性检查器>模拟指标

  • 设置底栏重视不透明工具栏

  • 将条形按钮项拖动到此模拟工具栏中

但是,当我跑步时该应用程序,此模拟工具栏不可见。

However, when I run the app, this "Simulated Toolbar" is not visible.

我无法通过Connections Inspector将模拟工具栏链接到IBOutlet

I am unable to link the simulated toolbar to an IBOutlet via the Connections Inspector

我还没有办法将工具栏对象(第一张图片)链接到模拟工具栏(第二张图片)。

I have not found a way to link the "toolbar object" (first image) to the "simulated toolbar" (second image).

我的主要目标是在故事板中看到工具栏的直观表示。这可能吗?

My main goal here is to see a visual representation of the Toolbar in the Storyboard. Is this possible?

推荐答案

模拟的指标只是 - 模拟的。它们可以帮助您可视化您的设计,但工件不一定会在运行时显示,而不是其他一些机制。您在故事板中创建的工具栏在运行时存在,但未添加到视图中。这就是为什么它在场景的标题中。

Simulated metrics are just that -- simulated. They help you to visualize your design, but the artifacts won't necessarily show up at runtime short of some other mechanism. The toolbar that you created in the storyboard is there at runtime but not added to your view. That's why it's up in the header of the scene.

标准使用 UIToolbar 是允许 UINavigationController 来管理它。因此,当选择 UINavigationController 时,InterfaceBuilder的Attributes Inspector窗格中会有一个切换。

The standard use of UIToolbar is to allow a UINavigationController to manage it. So there is a toggle in InterfaceBuilder's Attributes Inspector pane when a UINavigationController is selected.

从那里你可以根据需要添加 UIBarButtonItem ,并将它们连接到<您的代码中有code> IBOutlet s。无需将工具栏连接到IBOutlet;您可以在运行时从 UINavigationController的 工具栏属性中获取它。

From there you can add UIBarButtonItems as needed, and hook them up to IBOutlets in your code. No need to hook up the toolbar to an IBOutlet; you can get it from your UINavigationController's toolbar property at runtime.

参见 Apple文档

这篇关于如何连接Xcode Storyboard的“模拟指标”工具栏到实际的IBOutlet UIToolbar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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