通过轻按手势进行选择时,情节提要板会丢失导航栏 [英] Storyboard loses navigation bar when segueing via tap gesture

查看:50
本文介绍了通过轻按手势进行选择时,情节提要板会丢失导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有两个场景:一个UIViewController(顶部带有导航栏)和一个UITableViewController。如果我在第一个场景中连接一个按钮以选择表格视图,那么一切看起来都很棒。但是,如果我在第一个场景中连接了点击手势以锁定到表格视图,则导航栏不会在Xcode的第二个场景中显示。运行该应用程序时,导航栏应会出现,但是在情节提要编辑器中它消失了。

My app has two scenes: a UIViewController with a navigation bar at the top, and a UITableViewController. If I wire up a button in the first scene to segue to the table view, everything looks great. However, if I wire up a tap gesture in the first scene to segue to the table view, then the navigation bar doesn't display in the second scene in Xcode. When the app is run, the navigation bar appears as it should, but in the storyboard editor it is gone.

是否需要做一些特殊的事情来保存使用轻按手势从一个场景切换到另一场景时,是否需要导航栏?为了实现轻击手势,我将其拖动到情节提要中的一个元素上,然后将控件从场景底部的轻击手势识别器图标拖到希望其锁定的场景上。然后为 segue类型选择 push。

Is there something special that needs to be done to preserve the navigation bar when segueing from one scene to another using a tap gesture? To implement the tap gesture, I dragged it onto one of the elements in my storyboard, then control dragged from the "tap gesture recognizer" icon at the bottom of the scene to the scene I wanted it to segue to. Then selected "push" for the segue type.

推荐答案

我以前从没注意到这一点,但是我确实看到了同样的事情。在我看来,这似乎是个错误,但也许苹果有理由这样做。您可以转到控制器的模拟指标,然后将顶部栏设置为导航栏,这将允许您设置标题并根据需要添加栏按钮项。

I never noticed this before, but I do see the same thing. This seems like a bug to me, but maybe Apple has a reason for doing this. You can go to the "Simulated Metrics" for your controller, and set the "Top Bar" to be a navigation bar, which will allow you to set the title and add a bar button item if you want.

这篇关于通过轻按手势进行选择时,情节提要板会丢失导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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