swift - 当我创建一个注销的segue时,导航 Controller 突然出现 - Swift

标签 swift uiviewcontroller uinavigationcontroller segue

所以我放置了一个注销按钮,并创建了一个到第一个 View Controller 的segue,用户可以在其中登录或注册。由于某种原因,当我创建 segue 时,在第一个 View Controller 中出现了一个导航 Controller ,就好像它是嵌入的,但事实并非如此。如果我删除 Segue,导航就会消失。我尝试创建一个新按钮,但出现了同样的问题。这是导航在我的应用程序中显示方式的屏幕截图。 P.S 我正在使用 Swift

Image here. Notice the navigation controller.

如果有人能帮我解决这个问题,我将非常感激。

最佳答案

您需要正确理解UINavigationController。无论UINavigationController是否是初始的,但是从您创建segue的位置来看,必须存在UINavigationController。因此,您将获得一个 UINavigationBar 和一个后退按钮。

您仍然可以通过将顶部栏选择为None,从UIStoryboard 中禁用该功能。

enter image description here

好吧,如果您希望通过编码来完成此操作,请在您的 ViewController 类中通过以​​下方式完成:

override func viewWillAppear(_ animated: Bool) {
    self.navigationController?.setNavigationBarHidden(true, animated: false)
}

如果您仍然遇到任何问题,请告诉我。

关于swift - 当我创建一个注销的segue时,导航 Controller 突然出现 - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50790714/

相关文章:

xcode - 带小数点的数学应用程序崩溃

swift - Swift 中 "Just"库的文本输出

ios - 根据页面 Controller 当前索引将 ScrollView 移动到下一页

objective-c - Storyboard View Controller 中的透明背景

swift - 以编程方式在indexpath.item处呈现一个UIViewController(嵌入在UITabBarController中)

iOS 8 : UINavigationController popping without animation and then pushing

ios - CGContextDrawImage (Swift) 上的间歇性 "incorrect checksum for freed object"错误

objective-c - UINavigationController initWithRootVC : how to force the VC to load?

ios - InAppSettingsKit自动弹出UINavigationController?

ios - 如何在 Swift 的第一个 ViewController 中隐藏导航栏?