我有一个带有 4 个选项卡栏的选项卡栏 Controller 。我有子类选项卡栏 Controller ,并在选项卡栏 Controller 的 View 上添加了 UIView。 我想在 UIView 中添加一个 View Controller 作为 subview 或 subview Controller 。我已经做到了
let nvc : UIViewController = self.storyboard?.instantiateViewController(withIdentifier: "SongDetailVC") as! SongDetailsVC
nvc.willMove(toParentViewController: self)
playerMainView.addSubview(nvc.view)
self.addChildViewController(nvc)
nvc.didMove(toParentViewController: self)
但问题是,使用此代码我只能添加 SongDetailVC 的 View 。虽然我也想添加导航栏。
我尝试将 SongDetailVC 嵌入到导航 Controller 中。 我无法获得导航栏。
有什么办法可以实现这一点吗? ?
最佳答案
如果您的 SongDetailVC 嵌入到 UINavigationController 中,并且您也需要 UINavigationController,那么您将需要实例化 UINavigationController。确保在 Storyboard中设置标识符。
关于ios - 在 TabBarController 中添加 View Controller 作为带有导航栏的 subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50683422/