如何在 Interface Builder 中让 UIView 显示其导航控制器的导航栏

发布于 2024-11-29 23:39:07 字数 350 浏览 5 评论 0原文

我有一个 UINavigationController,我在导航控制器下添加了一个 UIViewController。

基本功能运行良好,我可以单击视图控制器中的一个项目,它会将我带到第二个视图,并且我可以使用后退按钮返回。

我的问题是,当我在 IB 中时,当我编辑将位于 NavController 下的 VC 时,有没有办法告诉 VC“嘿,假装顶部有一个导航栏,这样我就可以考虑到导航栏来布置此视图”?当我打开将位于导航下方的 VC 的 xib 文件时,它会向我显示要编辑的完整视图,然后当它加载时,它会缩小并移动内容,一切都很好。但我可能想要一个以某种方式适合屏幕的特定视图,并且在构建将在导航控制器下使用的视图时,将标题栏放在顶部作为参考会很好。

I have a UINavigationController, I've added an a UIViewController under the nav controller.

The basic functionality is working fine, I'm able to click an item in my view controller and it takes me to a second view and I can use the back button to go back.

My question is, when I'm in IB, is there a way when I'm editing a VC that is going to be under a NavController to tell the VC "hey, pretend there is a nav bar at the top so that I can lay this view out with that nav bar in mind"? When I open up the xib file for the VC that is going to be under the Nav it shows me a full view to edit, and then when it gets loaded in it shrinks and shifts things and everything is good. But I may want a specific view that fits a certain way on the screen, and having the title bar up top would be nice as a reference when building a view that is going to be used under a nav controller.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一江春梦 2024-12-06 23:39:07

在IB中选择主UIView。在属性中,转到属性检查器。您将看到“模拟指标”。顶部栏有一个下拉菜单。将其设置为导航栏。

Select the main UIView in IB. In the properties, go to the Attributes Inspector. You'll see "Simulated Metrics". There is a pulldown for Top Bar. Set it to Navigation Bar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文