swift - 呈现带有标签栏的 View Controller

标签 swift uitabbarcontroller tabbar

我在 AppDelegate 中以编程方式创建了 UITabBarController,并带有 4 个 View Controller (使用 .xib)。当用户点击 ViewController (VC-A) 上的某个按钮时,它会显示另一个 VC (VC-B) 并覆盖选项卡栏。所以我想让VC-B的按钮上有一个标签栏。

我尝试将 VC-B 添加为 tabbarcontroller 的子级。我尝试在 VC-A 和 VC-A.TabBarController 上进行 .present(vc) 和 .show(vc)

在 AppDelegate 中创建 Controller :

 let controllers = [tabViewController1,tabViewController2,tabViewController3,tabViewController4]
 tabBarController.viewControllers = controllers
 window?.rootViewController = tabBarController

在 VC-A 中展示

self.tabBarController?.present(controller, animated: false, completion: nil)

最佳答案

右键单击并将 Storyboard中的选项卡栏 Controller 拖动到 VC-B。这应该在 VC-A 和 VC-B 的底部创建一个选项卡,以便来回切换,而无需实现任何后端代码,除非您想要制作动画

关于swift - 呈现带有标签栏的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55958804/

相关文章:

ios - 从 View Controller 过渡到选项卡栏 Controller ,并在每个选项卡错误处使用导航 Controller

iOS:如何给`tabbar` 添加阴影?

iphone - 在 IOS 的 Cocoa Touch Tab Bar 应用程序前面添加登录屏幕

ios - 可以以编程方式点击文本字段并粘贴用户名/密码吗?登录名未保存在钥匙串(keychain)中

ios - 如何将颜色渐变应用于 UILabel 的背景?

swift - 向 Swift 包管理器提供配置文件

iphone - 如何从选项卡栏获取indexOfObject?

ios - 如何隐藏 iOS 框架的私有(private)模块?

ios - Swift 中带有 Unwind Segue 的 UITabBarController 不工作

iphone - 保留用户自定义的选项卡栏项目