[ad_1]
I am nonetheless new to iOS, Swift and SwiftUI…
I created a content material view utilizing a SwiftUI after which I added the view to my view controller in Swift
let childView = UIHostingController(rootView: ChildUIView())
addChild(childView)
childView.view.body = viewController.bounds
viewController.addSubview(childView.view)
The code above works nice, however then how can I goal a view that is in my rootView SwiftUI
In Android Java, I can do one thing like this
ScrollView scrollView = childView.findViewById(R.id.scrollview);
Right here in my Swift file, I strive to do that
let scrollView = childView.rootView.id(scrollView)
However I do not know if that is the best syntax to make use of
After which I am attempting to move the information sort as a ScrollView.
let scrollView: ScrollView = childView.rootView.id(scrollView) as! ScrollView
However I am getting an error saying, Generic parameter Content material couldn't be inferred in solid to ScrollView.
In all probability, I get this error as a result of I do not know the way it’s carried out.
Can anybody assist me out?
[ad_2]
