Ios 获取视图控制器中已取消弹出对话框的通知

Ios 获取视图控制器中已取消弹出对话框的通知,ios,swift,Ios,Swift,我有一个项目,是利用弹出对话框的工作非常好 将创建一个对话框,如下所示: let ratingVC = PopupViewController(nibName: "PopupViewController", bundle: nil) ratingVC.apiKey = self.apiKey ratingVC.accountNumberString = accountNumberString let popup = PopupDi

我有一个项目,是利用弹出对话框的工作非常好

将创建一个对话框,如下所示:

let ratingVC = PopupViewController(nibName: "PopupViewController", bundle: nil)
        ratingVC.apiKey = self.apiKey
        ratingVC.accountNumberString = accountNumberString        

        let popup = PopupDialog(viewController: ratingVC, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true)
        ratingVC.presentedPopup = popup
self.present(popup, animated: true, completion: nil)
允许自定义视图控制器在弹出窗口中工作。在
PopupViewController
中,可以使用
self.disclose(动画:true)

这工作得很好,但是我不确定启动视图控制器(self.present在其中运行)将如何得到弹出对话框已被取消的通知

我试过了

override func dismiss(animated flag: Bool, completion: (() -> Void)?)
    {
        super.dismiss(animated: flag, completion:completion)

    }

在启动视图控制器中,但不会调用它。

您可以创建一个
PopupViewControllerDelegate
,如中所述,如下所示

protocol PopupViewControllerDelegate:class {
    func viewControllerDidDismiss(_ sender: PopupViewController)
}

class PopupViewController: UIViewController {
     ...
     weak var delegate: PopupViewControllerDelegate?
     ...
}
并在ViewController关闭时调用它

然后在启动视图控制器中实现
PopupViewControllerDelegate
协议,并在创建PopupViewController时进行设置:

let ratingVC = PopupViewController(nibName: "PopupViewController", bundle: nil)
ratingVC.delegate = self
...

您可以创建一个类似中所述的
PopupViewControllerDelegate
,如下所示

protocol PopupViewControllerDelegate:class {
    func viewControllerDidDismiss(_ sender: PopupViewController)
}

class PopupViewController: UIViewController {
     ...
     weak var delegate: PopupViewControllerDelegate?
     ...
}
并在ViewController关闭时调用它

然后在启动视图控制器中实现
PopupViewControllerDelegate
协议,并在创建PopupViewController时进行设置:

let ratingVC = PopupViewController(nibName: "PopupViewController", bundle: nil)
ratingVC.delegate = self
...

根据您正在使用的
PopupDialog
的文档,弹出窗口的按钮具有完成块,您可以在其中捕获对话框是否将被取消

或者,现在可以做的最简单的方法是在
PopupDialog
实例化中添加完成块

像这样:

发件人:

let popup = PopupDialog(viewController: ratingVC, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true)
致:


让我知道这是否有帮助

根据您正在使用的
PopupDialog
的文档,弹出窗口的按钮具有完成块,您可以在其中捕获对话框是否将被取消

或者,现在可以做的最简单的方法是在
PopupDialog
实例化中添加完成块

像这样:

发件人:

let popup = PopupDialog(viewController: ratingVC, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true)
致:


让我知道这是否有帮助

可能会在dismise
self.dismise(动画:true){//fire notification或set delegate}
中触发通知或创建委托,也可能会在dismise
self.dismise(动画:true){//fire notification或set delegate}
中触发通知或创建委托,唉,这似乎不起作用,我猜是因为我直接调用Disclease而不使用PopupDialog内置按钮?唉,这似乎不起作用,我猜是因为我直接调用Disclease而不使用PopupDialog内置按钮?