Hello, I’m trying to present my custom SwiftUI dialog with text field in UIKit with modalPresentationStyle = .overFullScreen, but it leads to the UI being completely frozen once I select the TextField and memory constantly leaking. The minimal reproducible code is:
class ModalBugViewController: UIViewController {
var hostingController: UIHostingController<Content>!
struct Content: View {
@State private var text = ""
var body: some View {
ZStack {
Color.black.opacity(0.5).ignoresSafeArea()
VStack {
TextField("Test", text: $text)
.textFieldStyle(.roundedBorder)
.padding()
}
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .clear
hostingController = UIHostingController(rootView: Content())
addChild(hostingController)
view.addSubview(hostingController.view)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor)
])
hostingController.didMove(toParent: self)
}
}
And then in UIKit source view:
let viewController = ModalBugViewController()
viewController.modalPresentationStyle = .overFullScreen
present(viewController, animated: true)
The bug is reproducible on iOS 18 - 26.1, even on the simulator, although on iOS 26 it's in landscape mode only. Is there some workaround for this issue that doesn't involve rewriting the whole dialog in UIKit?