SwiftUI views do not respond in UIKit UIViewController

I have a Storyboard lifecycle application which has a UIViewController as window root view controller.

When I am trying to add the UIHostingController(SwiftUI view wrapped inside) to this root view controller as child view controller, the buttons and text fields in swiftUI view do not respond.

But when I am adding this UIHostingController as window root view controller or Navigation view controller's top view controller, then the swiftUI views respond in this case.

Please help me if I am missing anything

Below is the code that is used for adding the UIHostingController as child view controller which doesn't work
Code Block objective-c
[self addChildViewController:hostingController];
[self.view addSubview:hostingController.view];
[hostingController didMoveToParentViewController:self];

This is the code that works (in delegate)
Code Block objective-c
[window setRootViewController:hostingController];

OR this code

Code Block objective-c
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:hostingController];
[window setRootViewController:navController];



Hi, I am searching a way to present SwiftUI wrapping in UIKit view too. My target is to integrate SwiftUI views into an existing objective-c UIKit app.
I've tried
Code Block
[UIView addSubView: mySwiftUICtrl.view]
in many ways, but all get frustrated results that my SwiftUI view doesn't respond.

Finally I found a way to get my SwiftUI UIHostingController works. That is using MainViewController to present my UIHostingController:
Code Block
[mainViewCtrl presentViewController:mySwiftUICtrl animated:true completion:nil];
and mySwiftUICtrl works normally.

(I guess that the mystery "msgchain" in main controller needs to be pass through the UIHostingController.)
Recently I found that besides present ViewController directly, SwiftUI View can also be add to UIKit view as a subview.
For example:
Code Block
[self addChildViewController:hostingController];
[self.view addSubview:hostingController.view];
[hostingController didMoveToParentViewController:self];

we also need constraints swiftui in UIKit manually:
Code Block
UIView* view = hostingController.view;
view.translatesAutoresizingMaskIntoConstraints = false;
NSArray* constrants = [NSArray arrayWithObjects:
[ctrl.view.topAnchor constraintEqualToAnchor: view.topAnchor],
[ctrl.view.leftAnchor constraintEqualToAnchor: view.leftAnchor],
[ctrl.view.bottomAnchor constraintEqualToAnchor: view.bottomAnchor],
[ctrl.view.rightAnchor constraintEqualToAnchor: view.rightAnchor], nil ];
[NSLayoutConstraint activateConstraints: constrants];
SwiftUI views do not respond in UIKit UIViewController
 
 
Q