I am integrating a swift UI view in a UIKit application, my swift ui view is cut off when switching from portrait mode to landscape mode. I have followed tutorial online and my ViewController looks like:
@IBSegueAction func embedSwiftUIView(_ coder: NSCoder) -> UIViewController? {
return UIHostingController(coder: coder, rootView: MySwiftUIView()
)
}
My SwiftUI view just renders some placeholder text:
var body: some View {
Text("Placeholder")
}
Everything works ok in the preview in both landscape and portrait but when use the simulator (run the app). I get a blank screen on landscape mode (as if the text was cut off)
Preview:
Simulator:
What could I be doing wrong? I have tried so many things, geometryreaders etc nothing works?
What could I be doing wrong? I have tried so many things, geometryreaders etc nothing works. I want the simulator to behave like the preview and have the text in the center