Skip to content
New issue

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

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

Already on GitHub? # to your account

dismiss callback not working with custom VC #92

Closed
jf-gallo opened this issue Jan 13, 2017 · 3 comments
Closed

dismiss callback not working with custom VC #92

jf-gallo opened this issue Jan 13, 2017 · 3 comments

Comments

@jf-gallo
Copy link

jf-gallo commented Jan 13, 2017

Report

Environment

  • Mac OS version (e.g. 10.12): 10.12.2
  • Xcode version (e.g. 8.0): 8.1
  • PopupDialog version (e.g. 0.5.0): Latest
  • Minimum deployment target (e.g. 9.0): 9
  • Language (Objective-C / Swift): swift
  • In case of Swift - Version (e.g. 3.0): 3

Dependency management

  • Dependency manager (e.g. CocoaPods): Cocoapods
  • Version (e.g. 1.1.0): 1.1 .1

What did you do?

create a custom view controller Popup view with dismiss callback

    let popup = storyboard?.instantiateViewController(withIdentifier: "alerts") as! AlertsViewController

    let alert = PopupDialog(viewController: popup, gestureDismissal: true) {
        print("dismiss callback")
     }

    self.present(alert, animated: true) {
    }

What did you expect to happen?

callback to be triggered on dismiss

What happened instead?

callback was not triggered on dismiss.

Also wanted to add, that I have done this exact procedure with a Normal Popup Dialogue, (e.g not custom) and the callback WAS triggered.

@mwfire
Copy link
Member

mwfire commented Jan 13, 2017

@huffmann the default dialog is also using a custom view controller internally. When you are using your own custom view controller and the completion handler is not triggered, this usually hints to a retain cycle related to your custom view controller. Instruments and/or memory graph debugger will help you to identify the problem.

@mwfire
Copy link
Member

mwfire commented Jan 13, 2017

You can also have a look at the example at #87, which covers some best practices when using custom view controllers.

@jf-gallo
Copy link
Author

Awesome that was it!

Just for anyone's reference, to stop retain cycle simply add weak to your mainViewController reference in customViewController.
(e.g)
weak var homeVC : HomeViewController?

Thanks a lot. Its all working now.

@mwfire mwfire closed this as completed Jan 13, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants