I have a UICollectionView and I'm trying to design my UICollectionViewCell's using SwiftUI. I've seen two examples, one and two that have done this in the following manner in their UICollectionViewCell:
let controller = UIHostingController(rootView: SomeSwiftUIView)
let view = controller.view!
view.translatesAutoresizingMaskIntoConstraints = false
addSubview(view)
NSLayoutConstraint.activate([
view.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
view.topAnchor.constraint(equalTo: contentView.topAnchor),
view.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
view.bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
])
This works fine visually, but a problem I'm having is I do not have user interaction with the SwiftUI view. For example, if I have a Button in the SwiftUI view, the action is not performed when you tap the button. If a List is in the SwiftUI view, you cannot scroll this view. (I'm not trying to put a List in it, this is just an example)
Any recommendations on where to go from here? Thanks!