gpt4 book ai didi

ios - UIViewController 容器不显示 ChildViewController

转载 作者:行者123 更新时间:2023-11-30 11:23:36 24 4
gpt4 key购买 nike

我尝试实现左侧面板,但是当我实现时,它似乎除了容器之外不会显示任何内容。

下面是我的代码:

override func viewDidLoad() {
super.viewDidLoad()
initCenter(screen: showVC)
}

func initCenter(screen: ShowWhichVC) {
var presetingController: UIViewController
showVC = screen

if dashboardVC == nil {
dashboardVC = UIStoryboard.dashboardController()
dashboardVC.delegate = self
}
presetingController = dashboardVC
if let con = centerController {
con.view.removeFromSuperview()
con.removeFromParentViewController()
}
centerController = presetingController
view.addSubview(centerController.view)
self.addChildViewController(centerController)
centerController.didMove(toParentViewController: self)
}



private extension UIStoryboard {

class func mainStoryboard() -> UIStoryboard {
return UIStoryboard(name: "Main", bundle: Bundle.main)
}

class func leftPanelController() -> LeftPanelController? {
return mainStoryboard().instantiateViewController(withIdentifier: "LeftPanelController") as? LeftPanelController
}

class func dashboardController() -> DashboardController? {
return mainStoryboard().instantiateViewController(withIdentifier: "DashboardController") as? DashboardController
}
}

注意:DashboardControllerLeftPanelController UI 是以编程方式编写的,这有什么关系吗?谢谢!

Update GMS


2018-06-24 02:05:46.791965+0800 Pegasus[32657:577667] Google Maps SDK for iOS 和 Google Places API for iOS 版本:2.7.30514.0
2018-06-24 02:05:46.808461+0800 Pegasus[32657:577704] TIC 读取状态 [2:0x0]: 1:57
2018-06-24 02:05:46.808596+0800 Pegasus[32657:577704] TIC 读取状态 [2:0x0]: 1:57

我认为现在它与 GMSMapview 有关

最佳答案

我找到了解决办法!经过彻底检查,我发现 centerController View 大小设置为 0,所以我所做的是为其添加一个绑定(bind)到屏幕的大小尺寸。

centerController.view.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height)

关于ios - UIViewController 容器不显示 ChildViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51003551/

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