I am adding a SwiftUi view to my story board via UIHostController. The integration works and I have full functionality of buttons and image taps, however the Tabview at the bottom of the screen requires a long press in order for the Tabview to work and switch for me. If I run the same SwiftUI file within a swift application (no uikit, nor uihostcontroller) it works as intended. It has to be something with the UIhostcontroller or the way I am wrapping the swiftui view. Again the tabview does work but it would take someone forever to figure out you have to press and hold the button to get the page to switch. Anyone know what might be going on?
import UIKit import SwiftUI import FirebaseAuth import FirebaseAuthUI
class ViewController: UIViewController {
let contentView = UIHostingController(rootView: ContentView())
override func viewDidLoad(){
super.viewDidLoad()
// Do any additional setup after loading the view.
addChild(contentView)
view.addSubview(contentView.view)
setupConstraints()
}
fileprivate func setupConstraints(){
contentView.view.translatesAutoresizingMaskIntoConstraints=false
contentView.view.topAnchor.constraint(equalTo:view.topAnchor).isActive=true
contentView.view.bottomAnchor.constraint(equalTo:view.bottomAnchor).isActive=true
contentView.view.leftAnchor.constraint(equalTo:view.leftAnchor).isActive=true
contentView.view.rightAnchor.constraint(equalTo:view.rightAnchor).isActive
= true
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}