Closed nickthedude closed 5 years ago
Any help on this?
Looking at the code is it possible the completion handler member variable is ignored because the argument coming into the dismiss method being overridden has the same name?
Hey there! Please excuse my late reply. Usually, when the completion handler is not called, it is due to a custom view controller that is not deinitialized. Can you confirm?
It's definitely a custom view controller. Not sure im understanding about deinitialization. It was presented, now being dismissed, are you saying something is retaining a reference or something?
The completion handler is called once the dialog was deinitialized. https://github.com/Orderella/PopupDialog/blob/30ffc27a2727f91aeaff737d4cd667f0b37fa5f9/PopupDialog/Classes/PopupDialog.swift#L220-L223
I am still thinking about moving this back to the real dismissal, on the other hand you know there is a retain cycle if the completion handler is not called. This could be due to strong references in one of the button actions or completion handler. If you are referring to the dialog or the view controller in one of these, make sure to use weak references, e.g.
button.action = { [weak dialog] in
dialog?.doSomething()
}
Does that help?
I’ll give it a go
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Report
Environment
Please provide information on your development environment, so we can build with the same scenario.
Dependency management
If you are not using any dependency managers, you can remove this section.
What did you do?
I am presenting a viewcontroller without any buttons so the only way to dismiss is by either gesture or tapping off view.
What did you expect to happen?
The completion block to be called
What happened instead?
when dismiss was called on the popupdialog the completion was nil, it wasn't nil in the init function
Project that demonstrates the issue