![](/img/trans.png)
[英]How to Change height of Container view (Parent view) according to Childviewcontroller (Different size of UIViewController) height?
[英]UIViewController Container not showing ChildViewController
我嘗試實現一個左側面板,但是無論何時實現,似乎除了容器之外什么都不會顯示。
這是我的代碼如下:
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
}
}
注意: DashboardController
和LeftPanelController
UI是用編程方式編寫的,這與它有關嗎? 謝謝!
更新GMS
2018-06-24 02:05:46.791965+0800 Pegasus[32657:577667] Google Maps SDK for iOS and Google Places API for iOS version: 2.7.30514.0 2018-06-24 02:05:46.808461+0800 Pegasus[32657:577704] TIC Read Status [2:0x0]: 1:57 2018-06-24 02:05:46.808596+0800 Pegasus[32657:577704] TIC Read Status [2:0x0]: 1:57
我認為現在它與GMSMapview有關
我找到了解決方案! 在對其進行徹底檢查時,我發現將centerController
視圖大小設置為0
,所以我要做的是向其添加一個與屏幕大小綁定的大小。
centerController.view.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.