Hi All,
I am trying to add an UIHostingViewController to my UIViewController, to cover the screen. Unfortunately, I keep getting this error (Thread 1: "NSLayoutConstraint for <_TtGC7SwiftUI19UIHostingControllerV5Pickt10ViewRouter_: 0x7fa32a37c3f0>: Constraint items must each be a view or layout guide."
) from my code:
let controller = UIHostingController(rootView: ViewRouter(join: join, create: create, showPicker: showPicker, setMock: setMock))
controller.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(controller.view)
view.addConstraints([
NSLayoutConstraint(item: controller,
attribute: .top,
relatedBy: .equal,
toItem: view.safeAreaLayoutGuide,
attribute: .top,
multiplier: 1,
constant: 0),
NSLayoutConstraint(item: controller,
attribute: .leading,
relatedBy: .equal,
toItem: view.safeAreaLayoutGuide,
attribute: .leading,
multiplier: 1,
constant: 0),
NSLayoutConstraint(item: controller,
attribute: .trailing,
relatedBy: .equal,
toItem: view.safeAreaLayoutGuide,
attribute: .trailing,
multiplier: 1,
constant: 0),
NSLayoutConstraint(item: controller,
attribute: .bottom,
relatedBy: .equal,
toItem: view.safeAreaLayoutGuide,
attribute: .bottom,
multiplier: 1,
constant: 0)
])