I have created a "HorizontalSplit"-UIViewController
. In that I created two UIView
s as containers for other UIViewController. The height of the Containers is the half of the Screen.
override func viewDidLoad() {
super.viewDidLoad()
...
self.topViewContainer = UIView(frame: CGRectMake(0, 0, self.view.bounds.width, completeHeight / 2))
self.topViewContainer.backgroundColor = UIColor.orangeColor()
self.view.addSubview(topViewContainer)
self.bottomViewContainer = UIView(frame: CGRectMake(0, completeHeight / 2, self.view.bounds.width, completeHeight / 2))
self.bottomViewContainer.backgroundColor = UIColor.blueColor()
self.view.addSubview(bottomViewContainer)
...
}
After that I put a new Controller in that View an used these lines of code:
func setTopViewController(viewController: UIViewController) {
if self.topViewController != nil {
self.topViewController.removeFromParentViewController()
self.topViewController.view.removeFromSuperview()
}
var l = topViewContainer.frame.height
self.topViewController = viewController
self.topViewController.view.frame = CGRect(x: 0, y: 0, width: topViewContainer.bounds.width, height: topViewContainer.bounds.height)
var o = topViewController.view.frame.height
self.addChildViewController(self.topViewController)
self.topViewContainer.addSubview(self.topViewController.view)
self.topViewController.didMoveToParentViewController(self)
}
I want that the SubViewController-Frame-Size (here called simple viewController) have the same size like the UIView-container that I added before. It works here because l and o (the variables) says the right height. But when my ViewController that I setup via the setTopViewController method on the HorizontalViewContrller the size is'n correct anymore. When I call on viewDidLoad 'self.view.bounds.height' on the subViewController it called the full size! And not the size I have set before... Why?