SystemNotification in UIKit app preventing touch events
I'm trying to integrate SystemNotification to a UIKit-only app using addAsOverlay.
Here's the setup code:
// Setup system notification
self.systemNotificationContext = SystemNotificationContext()
self.systemNotification = SystemNotificationUIKitOverlay(context: self.systemNotificationContext)
self.systemNotification.addAsOverlay(to: self.view)
In our app, we are showing a modal pageSheet view where users can enter data and when completed a new item added notification would be shown.
However as soon as I add the SystemNotification as an overlay, all touch events are not reaching the actual buttons underneath the overlay.
Removing the setup code above restores the touch events.
Anything I should look for?
OK, so after some reseeach, looks like the UIHostingViewController is capturing all touch events from going underneath the overlay.
I've added this code which seems to resolve my issue. Not sure what the impact is on events handled by the SystemNotification however
SystemNotificationUIKitOverlay.swift:36
func addAsOverlay(to view: UIView) {
let overlay = UIHostingController(rootView: self)
// Disable user interaction for overlay
overlay.view.isUserInteractionEnabled = false
view.addSubview(overlay.view)
Hi @martindufort
Oh, I haven't looked at the UIKit support stuff for a long time.
Does it work to swipe away the notification if you add that line?
Will try but my first guess is no.
@martindufort Since I rarely touch UIKit these days, feel free to make any adjustments that work for you and I'll happily merge it 😀
Will do and add a version for AppKit as well. 😉
This issue was closed with PR #18.