【问题标题】:Start a storyboard view in UITabBar在 UITabBar 中启动故事板视图
【发布时间】:2018-11-03 03:07:03
【问题描述】:

我正在尝试以编程方式在不同情节提要文件中的 UITabBarController 中启动 UIView。

WelcomeVC.swift 中,它没有UITabBar 并且位于Main.storyboard 中。当单击 UIButton 时,它会调用 UITabBar ViewController

@objc func startMatching(sender: UITapGestureRecognizer){
    let storyBoard: UIStoryboard = UIStoryboard(name: "Test", bundle: nil)
    let pdv = storyBoard.instantiateViewController(withIdentifier: "AVC") as! AVC
    self.present(pdv, animated: true, completion: nil)
}

Test.storyboard 中,它包含1 个UITabBarController 和2 个视图控制器:AVCBVC。如果我们在它们上调用 present(),它们都会按预期运行,但 UITabBar 不会出现。

如何让标签控制器显示出来?

【问题讨论】:

    标签: ios swift storyboard uitabbarcontroller


    【解决方案1】:

    你必须展示UITabBarViewController,给它一个故事板标识符并展示它,而不是直接展示AVC

    let storyBoard: UIStoryboard = UIStoryboard(name: "Test", bundle: nil)
    let pdv = storyBoard.instantiateViewController(withIdentifier: "TabBarViewController") as! UITabBarViewController
    self.present(pdv, animated: true, completion: nil)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-06
      • 1970-01-01
      • 2014-08-31
      • 1970-01-01
      • 1970-01-01
      • 2018-11-27
      相关资源
      最近更新 更多