将子视图控制器添加到UITabBarController问题

时间:2019-05-07 07:29:30

标签: ios swift uitabbarcontroller childviewcontroller

我正在尝试将UIViewController作为子视图控制器添加到选项卡栏控制器。参见下面的代码:

guard let vc = self.storyboard?.instantiateViewController(withIdentifier: "MyAlertViewController") as? MyAlertViewController else
{
    return
}

let base: UITabBarController = tabBarController!
base.addChildViewController(vc)
vc.view.frame = base.view.bounds
base.view.addSubview(vc.view)
vc.didMove(toParentViewController: base)

它可以工作,但是有一个我无法解决的问题:MyAlertViewController被添加到标签栏控制器的viewControllers数组中,有时甚至显示为标签栏项。有办法解决吗?谢谢。

0 个答案:

没有答案
相关问题