Orderella / PopupDialog

A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.
http://www.mwfire.de
Other
3.95k stars 521 forks source link

Re-present dialog after it is dismissed #351

Closed simonhopkin closed 4 years ago

simonhopkin commented 4 years ago

Report

Environment

Dependency management

What did you do?

I tried to present a popup dialog after it has been previously dismissed.

What did you expect to happen?

The popup dialog should re-appear.

What happened instead?

The background blurred but no popup dialog appeared.

However if you use the .fadeIn transition style the popup dialog does appear. The issue is only caused with bounce and zoom transition styles.

Project that demonstrates the issue

The code below reproduces the issue:

    let popupDialog = PopupDialog(title: "Dialog Title", message: "Dialog Message", transitionStyle: .bounceUp)

    viewController.present(popupDialog, animated: true, completion: {
        popupDialog.dismiss {
            viewController.present(popupDialog, animated: true, completion: nil)
        }
    })

You can see the popup initially appears, and is then dismissed. An attempt is made to present the dialog again but all that appears is the background blur.

If you replace the transitionStyle with .fadeIn you can see the popup appear, disappear and re-appear as expected.

I have submitted the following pull request to fix this issue: https://github.com/Orderella/PopupDialog/pull/350

stale[bot] commented 4 years ago

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.

simonhopkin commented 4 years ago

bump

ahmedsafadii commented 4 years ago

@simonhopkin you need to know that you are trying to preset the popup inside the popup which already has been dismissing.

the solution for this is just to create delegate or nonfiction center, I prefer to delegate to trigger when the popup dialog dismiss.

ahmedsafadii commented 4 years ago

Simple Example would be like this

// PopupDialog Controller

// Outer Class
protocol ShowAnotherPopUpDelegate: class {
   func didDismiss()
}

// Insider Class
weak var dismissDelegate: ShowAnotherPopUpDelegate?

// Now inside the button that dismisses the popup call
dismissDelegate.didDismiss()

// Home Control that preset the pop-up

let popupDialog = PopupDialog(title: "Dialog Title", message: "Dialog Message", transitionStyle: .bounceUp)
popupDialog.dismissDelegate = self

viewController.present(popupDialog, animated: true, completion: nil)

Now just inheritance ShowAnotherPopUpDelegate
extension ViewController: ShowAnotherPopUpDelegate {

func didDismiss() {
// show the pop here or do something
}
} 

Another solution I don't know if it will works

        let popupDialog = PopupDialog(title: "Dialog Title", message: "Dialog Message", transitionStyle: .bounceUp)

        viewController.present(popupDialog, animated: true, completion: {
            popupDialog.dismiss {
                DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                    viewController.present(popupDialog, animated: true, completion: nil)
                }
            }
        })
stale[bot] commented 4 years ago

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.