Skip to content

Commit 28bc292

Browse files
author
JWI
committed
a
1 parent 6a9d0b7 commit 28bc292

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

Sources/UIKitBackend/UIKitBackend+Window.swift

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,23 @@ final class RootViewController: UIViewController {
5959
childWidget?.removeFromParentWidget()
6060
child.removeFromParentWidget()
6161

62-
let childController = child.controller
6362
view.addSubview(child.view)
64-
if let childController {
65-
addChild(childController)
66-
childController.didMove(toParent: self)
67-
}
68-
childWidget = child
69-
70-
71-
72-
/*NSLayoutConstraint.activate([
73-
child.view.widthAnchor.constraint(equalTo: viewAnchor.widthAnchor),
74-
child.view.heightAnchor.constraint(equalTo: viewAnchor.heightAnchor),
75-
])*/
76-
77-
child.view.frame = view.bounds
7863
child.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
64+
childWidget = child
65+
66+
// Force layout immediately if view already has bounds
67+
if view.bounds != .zero {
68+
child.view.frame = view.bounds
69+
}
70+
}
71+
72+
override func viewDidLayoutSubviews() {
73+
super.viewDidLayoutSubviews()
74+
if let child = childWidget {
75+
child.view.frame = view.bounds
76+
}
7977
}
78+
8079
}
8180

8281
extension UIKitBackend {

0 commit comments

Comments
 (0)