Xcode 14 - Why embedded controller to container view is showing white space on top?

Viewed 24

I update my Xcode to v14.0 and build my current app on it, everything is working fine except Controllers embedded on a ContainerView, this been working fine until this Xcode update.

In the image 1 you can see my layout, and in the image 2 you can see what is showing when the view is added to the container, a space of the container it is still visible, but the child controller is working fine (the scroll, the actions. etc).

Image 1 - Layout Image 2 - Embedding Controller to UIView

Below the functions to add and remove the controller from the container view.

func add(child: UIViewController) {
    self.addChild(child)
    child.view.frame = self.containerView.frame
    self.containerView.addSubview(child.view)
    child.didMove(toParent: self)
}

func remove(child: UIViewController) {
    child.willMove(toParent: nil)
    child.view.removeFromSuperview()
    child.removeFromParent()
}

If I replace func add(child:_) for the code below I get the Image 3 (see below), instead of having part of the container I just go a black bottom area.

func add(child: BaseViewController) {
    self.addChild(child)
    child.view.frame = self.containerView.bounds
    self.containerView.addSubview(child.view)
    child.didMove(toParent: self)
}

Image 3 - Embedding with frame = bounds

Funny enough as I mention, this is just happening from this Xcode version. Does anyone having this same issue?

0 Answers
Related