gpt4 book ai didi

swift - 如何在 Swift 中呈现 UITabBarController

转载 作者:可可西里 更新时间:2023-11-01 00:38:10 25 4
gpt4 key购买 nike

我有一个故事公 pig ,它设置了一个带有按钮的 View 。当我单击该按钮时,我应该转到自定义 UITabBarController,但显示的只是一个空的标签栏。

let tabBar = TabViewController()
self.presentViewController(tabBar, animated: true, completion: nil)

在 Storyboard 中,我将 TabBarController 的类设置为 TabViewController。我错过了什么?

最佳答案

您需要在 Interface Builder 中为 TabViewController 提供 Storyboard ID,并通过以下方式访问它:

if let tabViewController = storyboard.instantiateViewControllerWithIdentifier("TheAssignedID") as? TabViewController {
presentViewController(tabViewController, animated: true, completion: nil)
}

您使用的代码只是创建了 TabViewController 类的一个新实例。不访问您在 Interface Builder 中定义的原型(prototype)。

关于swift - 如何在 Swift 中呈现 UITabBarController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26306557/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com