SwiftKickMobile / SwiftMessages

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

why didHide Source dismiss? #541

Closed LiuYimin closed 4 months ago

LiuYimin commented 4 months ago

source.dismiss(animated: false, completion: nil)

This line of code causes my original page to disappear. When I call SwiftMessage from the presented page, it causes issues.

Maybe change to presented.dismiss()?

LiuYimin commented 4 months ago

let segue = SwiftMessagesSegue(identifier: String(describing: vc.self), source: self, destination: vc) segue.configure(layout: .bottomMessage) segue.dimMode = .gray(interactive: true) segue.perform() The self is a model viewcontroller,when I tap dismiss the vc, self will be dismiss, too.So I so confuse the code "source.dismiss(animated: false, completion: nil)" in SwiftMessagesSegue.swift

wtmoose commented 4 months ago

@LiuYimin I think you need to review Apple's API documentation:

dismiss(animated:completion:) Dismisses the view controller that was presented modally by the view controller.

https://developer.apple.com/documentation/uikit/uiviewcontroller/1621505-dismiss

So source.dismiss(animated: false, completion: nil) is correct.

LiuYimin commented 4 months ago

Thank you very much. I've resolved the issue, and it wasn't because of this "source" (although changing "source" to "presented" could also solve my problem), but rather because when using SwiftMessage in a view controller presented using the .overCurrentContext style from a child view controller, the "source" would also dismiss my own view controller.