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
tcombs commented
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 SwiftUIView
, and a subclass ofUIHostingViewController
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 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
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
manu-r12 commented
Maybe consider wrapping the FloatingPanelController within a UIViewControllerRepresentable....