Post

Replies

Boosts

Views

Activity

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 [self addChildViewController:hostingController]; [self.view addSubview:hostingController.view]; [hostingController didMoveToParentViewController:self]; This is the code that works (in delegate) [window setRootViewController:hostingController]; OR this code UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:hostingController]; [window setRootViewController:navController];
2
0
4.9k
Jun ’21