SwiftKickMobile / SwiftMessages

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

SwiftMessage presented in Scroll View instead of top viewcontroller. #426

Closed annathomasQB closed 3 years ago

annathomasQB commented 3 years ago

Hi,

Saw this very strange behaviour (very rare - I couldn't reproduce it but a beta tester shared the screenshot so I have no other choice but to believe it)

The Custom Swift Message that I'd created using a custom xib file, was getting shown inside a scroll view of the view controller, (at least that's what I could understand from the screenshot shared). Device : iPhone 8 OS : iOS 14

I couldn't replicate the same in iPhone 8 simulator (iOS 13.4.1 though, since my XCode isn't updated)

For the record, the view controller has some three to 4 layers of nested view inside it, but I still can't understand why its detecting the scroll view as the most parent view.

(I'm colouring out the design since the app is still not out)

In the first screenshot, you can see the top part (which is supposed to be static), and part of the swift message popped up below that, inside the scroll view (see the darkened background on the left)

screenshot with issue

This is how it's supposed to come

screenshot without issue

What I could understand is, the top orange part has the subview scrollview inside that, and somehow swiftmessages must have calculated the scrollview to be the most top parent view.

Version of Swift Messages used : SwiftMessages (8.0.0)

wtmoose commented 3 years ago

Code?

annathomasQB commented 3 years ago
        DispatchQueue.main.asyncAfter(deadline: .now() + 0.75) {
            let alertView = MyClassAlertView(alertType: "name of popup", displaytext: "firstText", displayTextTwo: "secondText")
            alertView.delegate = self
            SwiftMessages.show(config: alertView.alertConfig, view: alertView)
        }

Have altered names and text and parameters passed (all are strings, which are used to display the text inside the popup)

wtmoose commented 3 years ago

You haven't shown what alertView.alertConfig, but my suggestion is to change presentationContext = .window(.normal) on the config to show your alert in a separate window above the app's window.

annathomasQB commented 3 years ago

oh Sorry :)

alertConfig is a var inside the custom alertView class

var alertConfig = SwiftMessages.Config()

Its properties are set as follows :

    private func setAlertConfig() {
        alertConfig.presentationStyle = .center
        alertConfig.duration = .forever
        alertConfig.interactiveHide = false
        alertConfig.shouldAutorotate = false
        alertConfig.dimMode = .color(color: UIColor.black.withAlphaComponent(0.71), interactive: false)
    }

I'll add this config property as well and try. But since this was a rare occurrence it was hard for the beta tester to reproduce. I'll but anyways update the new build with this change and check if it's occurring again or not. Please give me sometime to update back here :) Thanks for your input @wtmoose :)

wtmoose commented 3 years ago

Please reopen if you have further issues.