         
         let appDelegate = UIApplication.shared.delegate
         
-        let parentViewController = appDelegate?.window??.rootViewController
+        var parentViewController = appDelegate?.window??.rootViewController
+        
+        var modalViewController = parentViewController?.presentedViewController
+        
+        while modalViewController != nil {
+            parentViewController = modalViewController
+            
+            modalViewController = parentViewController?.presentedViewController
+        }
         
         parentViewController?.view.addSubview(self)
         

    
    // MARK: - Constructors
    
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        

        popupView.transform = CGAffineTransform(scaleX: 1.05, y: 1.05)
        popupView.alpha = 0.0
        
        UIView.animate(withDuration: animationDuration, animations: { () -> Void in
            self.overlayView.alpha = 1.0
            self.popupView.transform = CGAffineTransform.identity
            self.popupView.alpha = 1.0
        }, completion: { (finished) -> Void in
            
        })
    }
    
    // MARK: - Hide
