SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.3k stars 742 forks source link

iPad 13.5.1 hit test issue when presentationContext = .window #399

Closed FranckLetellier closed 4 years ago

FranckLetellier commented 4 years ago

When I create a card view, and present it at window level on iPad, the underlying view does not respond to touch. I managed to track the issue down to the following code :

class PassthroughWindow: UIWindow {

    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        let view = super.hitTest(point, with: event)
        return view == self ? nil : view
    }
}

On iPhone 13.5.1 (iphone X) everything works as expected, which mean when this code is called, view is equal to PassthroughWindow, the touch is send to the underlying view. Perfect !

However, on iPad (same code base), the view that is return by super.hitTest is a subview of UIDropShadowView. So the touch is not send to underlying view.

Capture d’écran 2020-07-09 à 18 58 44 Capture d’écran 2020-07-09 à 18 59 26

Here is the code use to present the message :

let messageview = MessageView.viewFromNib(layout: .cardView)
        messageview.configureTheme(.info)
        messageview.button?.isHidden = true
        messageview.iconImageView?.isHidden = true
        messageview.iconLabel?.isHidden = true
        messageview.titleLabel?.textColor = .white
        messageview.titleLabel?.textAlignment = .center
        messageview.tapHandler = { _ in

        }
        var config = SwiftMessages.defaultConfig
        config.presentationContext = .window(windowLevel: UIWindow.Level.normal)
        config.duration = .seconds(seconds: 3)
        messageview.configureContent(title: message, body: "")
        SwiftMessages.show(config: config, view: messageview)

And I have no clue how to fix this. I thought of checking for UIDropShadowView, but it seems we cannot access its definition.

wtmoose commented 4 years ago

This is a duplicate of #350. You can use the head of the master branch.

wtmoose commented 4 years ago

Included in 8.0.0 release

FranckLetellier commented 4 years ago

It works perfectly on 8.0.0. Thank you so much !