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 [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: [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.)
Post
Replies
Boosts
Views
Activity
Recently I found that besides present ViewController directly, SwiftUI View can also be add to UIKit view as a subview.
For example: [hostingController didMoveToParentViewController:self];
we also need constraints swiftui in UIKit manually: [NSLayoutConstraint activateConstraints: constrants];