You'll have to be more precise about the context in which you're placing this code. For instance addChild(_:)
is a method on a UIViewController
, and not on a UIView
. But frame
is a property on a UIView
, not a UIViewController
. So I don't know where you're getting the frame
from on the right hand side of the =
operator on line 4. If it's the parent view controller's view frame, then... frame
is the view's position in its super view's coordinate system, whereas bounds
is its position in its own coordinate system. So depending on frame
, maybe you're covering it up? But if you're trying to add the hosting controller onto the navigation stack, then you should be using pushViewController(_:_:)
not addChild(_:)
. And then, if you have navigationBarHidden(_:)
(which we don't know is not the case from the code you posted) in your swiftUI view, who knows, maybe the hosting controller is setting that property correctly, too? And if your swift view has a navigation view in it, I don't even know how much more could go wrong. But we can't see that from your example. If you have a particular bug in particular code, please construct a minimal example that still causes the bug, and post that, and then we can tell for sure.