    Sets should-dismiss handler of dialog which takes dialogView and tapped
    button and returns a boolean indicating if dialog should be dismissed.
    - Parameter handler: A closure handling if dialog can be dismissed.
-   - Returns: DialogBuilder itself to allow chaining.
+   - Returns: Dialog itself to allow chaining.
    */
   open func shouldDismiss(handler: ((DialogView, Button?) -> Bool)?) -> Dialog {
-    controller.shouldDismissHandler = handler
+    controller.shouldDismissHandler = { [unowned self] dialogView, button in
+      let d = self.delegate?.dialog?(self, shouldDismiss: button) ?? true
+      let h = handler?(dialogView, button) ?? true
+      return d && h
+    }
+    return self
+  }
+  
+  /**
+   Sets handler for when view controller will appear.
+   - Parameter handler: A closure handling the event.
+   - Returns: Dialog itself to allow chaining.
+   */
+  open func willAppear(handler: (() -> Void)?) -> Dialog {
+    controller.willAppear = { [unowned self] in
+      self.delegate?.dialogWillAppear?(self)
+      handler?()
+    }
+    return self
+  }
+  
+  /**
+   Sets handler for when view controller did disappear.
+   - Parameter handler: A closure handling the event.
+   - Returns: Dialog itself to allow chaining.
+   */
+  open func didDisappear(handler: (() -> Void)?) -> Dialog {
+    controller.didDisappear = { [unowned self] in
+      self.delegate?.dialogDidDisappear?(self)
+      handler?()
+      self.controller.dialog = nil
+    }
+    return self
+  }
+  
+  /**
+   Sets dialog delegate.
+   - Parameter delegate: A DialogDelegate.
+   - Returns: Dialog itself to allow chaining.
+   */
+  open func delegate(_ delegate: DialogDelegate) -> Dialog {
+    self.delegate = delegate
     return self
   }
   
   /**
    Presents dialog modally from given viewController.
    - Parameter _ viewController: A UIViewController.
-   - Returns: DialogBuilder itself to allow chaining.
+   - Returns: Dialog itself to allow chaining.
    */
   @discardableResult
   open func show(_ viewController: UIViewController) -> Dialog {
+    controller.dialog = self
     viewController.present(controller, animated: true, completion: nil)
     return self
   }

   Sets cancelability of dialog and handler for when it's cancelled.
   - Parameter _ value: A Bool.
   - Parameter handler: A closure handling cancellation.
   - Returns: DialogBuilder itself to allow chaining.
   */
  open func isCancelable(_ value: Bool, handler: (() -> Void)? = nil) -> Dialog {
    controller.isCancelable = value
    controller.didCancelHandler = handler
    return self
  }
  

   Sets title and handler for positive button of dialog.
   - Parameter _ title: A string.
   - Parameter handler: A closure handling tap.
   - Returns: Dialog itself to allow chaining.
   */
  open func positive(_ title: String?, handler: (() -> Void)?) -> Dialog {
    dialogView.positiveButton.title = title
    controller.didTapPositiveButtonHandler = { [unowned self] in
      self.delegate?.dialog?(self, didTapPositive: self.controller.dialogView.positiveButton)
      handler?()
    }
    return self
  }
  
