Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"onDismissal" closure doesn't execute when vc is dismissed with swipe #35

Open
lukemmtt opened this issue Sep 20, 2020 · 1 comment
Open

Comments

@lukemmtt
Copy link
Contributor

lukemmtt commented Sep 20, 2020

In my parent view controller, I've defined the following:

whatsNew.onDismissal = didDismissWhatsNew

But the closure only executes when the user clicks on the "continue" button at the bottom of the WhatsNew vc. It does not execute when the user dismisses the page sheet by swiping downward.

I'm no professional, but until someone figures out a generalized solution, I figured I'd share what I did to get around this.

Manual workaround:

First I modify my parent view controller to adhere to the UIAdaptivePresentationControllerDelegate protocol:

class PlannerViewController: UIViewController, UIAdaptivePresentationControllerDelegate {

Then in the parent vc's function where I initialize the WhatsNew vc, prior to calling whatsNew.presentIfNeeded(on: self), I set "self" as the presentationController delegate:

whatsNew.presentationController?.delegate = self

Lastly, in the parent VC, I implement the presentationControllerDidDismiss(_:) method and call the same dismissal action that I defined for whatsNew.onDismissal:

  func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
    didDismissWhatsNew()
  }
@arunas111
Copy link

I just used whatsNew.isModalInPresentation = true so users can't dismiss by swiping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants