2

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)

    

}

enter image description here

newbycoder
  • 51
  • 6
  • Also, I have tried another method of adding a UIhostcontroller to the storyboard and doing a Segue from the Container View in the ViewController to the Host Controller. It does transition and work but it also requires a long press on the Tabview icons. – newbycoder Oct 18 '22 at 11:41
  • I even recoded my Tabview in my SwiftUi that is showing in my UIHostingController in storyboard. Again everything works as intended but the tab buttons you have to long press in order to get them to switch any ideas? And I do not have any long press gesture enabled on any of my views. – newbycoder Oct 18 '22 at 18:52

0 Answers0