FloatingPanel
FloatingPanel copied to clipboard
FloatingPanel is not able to be interacted with when added to a UIHostingController in Xcode 16 beta with iOS 18 beta.
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
UINavigationControllerand a root view controller with a button. The button creates a SwiftUIView, and a subclass ofUIHostingViewControllerand 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
UIHostingViewControllercreates the floating panel and adds it inviewDidLoad
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
UIHostingViewControllerbehind 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