scenee/FloatingPanel

FloatingPanel is not able to be interacted with when added to a UIHostingController in Xcode 16 beta with iOS 18 beta.

Closed this issue · 2 comments

Description

When using the latest developer tools of Xcode 16 beta 4 and iOS 18, when a FloatingPanelController is added to a UIHostingController as its parent, the floating panel cannot be interacted with using touch events. All touch events pass through the floating panel to the view behind it.

Expected behavior

I should be able to add a FloatingPanelController to a UIHostingController and interact with the floating panel as normal.

Steps to reproduce

I have reproduced this in a project here

  • Create a project in Xcode using storyboards with a UINavigationController and a root view controller with a button. The button creates a SwiftUI View, and a subclass of UIHostingViewController and pushes the view controller.
class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }


    @IBAction func navigate(_ sender: Any) {
        let view = HostingControllerExampleView() //Any SwiftUI View
        let hostingViewController = MyUIHostingController(rootView: view)
        self.navigationController?.pushViewController(hostingViewController, animated: true)
    }
}
  • The subclassed UIHostingViewController creates the floating panel and adds it in viewDidLoad
class MyUIHostingController<Content>: UIHostingController<Content> where Content: View {
    
    var fpc: FloatingPanelController!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //Add panel to view
        fpc = FloatingPanelController()
        
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let drawerViewController = storyboard.instantiateViewController(withIdentifier: "Drawer")
        
        fpc.set(contentViewController: drawerViewController)
        fpc.addPanel(toParent: self)
    }
}
  • Anything in the drawer can not be interacted with and touch events go through to the UIHostingViewController behind the floating panel.

Environment

Library version
2.8.4

Installation method

  • Swift Package Manager

iOS version(s)
iOS 18 developer beta 4

Xcode version
Xcode 16 beta 4

Maybe consider wrapping the FloatingPanelController within a UIViewControllerRepresentable....

Thank you for your patience. I confirmed the project here, but the panel is working well on Xcode 16.0 (16A242d) and Xcode 16.1 (16B40). This issue maybe happens only on Xcode 16 beta versions, so I closed this. But feel free to reopen it if you still have a problem.