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.
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.
Description
When using the latest developer tools of Xcode 16 beta 4 and iOS 18, when a
FloatingPanelController
is added to aUIHostingController
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 aUIHostingController
and interact with the floating panel as normal.Steps to reproduce
I have reproduced this in a project here
UINavigationController
and a root view controller with a button. The button creates a SwiftUIView
, and a subclass ofUIHostingViewController
and pushes the view controller.UIHostingViewController
creates the floating panel and adds it inviewDidLoad
UIHostingViewController
behind the floating panel.Environment
Library version 2.8.4
Installation method
iOS version(s) iOS 18 developer beta 4
Xcode version Xcode 16 beta 4