         }, completion: { result in
             self.view.removeFromSuperview()
             self.removeFromParentViewController()
-        }) 
+        })
     }
-	
-	func calculatePopoverViewFrame() -> CGRect {
-		let popoverY = self.fromView.convert(self.fromView.frame.origin, to: self.view).y + self.fromView.bounds.height
-
+    
+    func calculatePopoverViewFrame() -> CGRect {
+        let popoverY = self.fromView.convert(self.fromView.frame.origin, to: self.view).y + self.fromView.bounds.height
+        
         let preferredContentSize = self.contentViewController.preferredContentSize
-		var popoverWidth = preferredContentSize.width
-		if popoverWidth == UIViewNoIntrinsicMetric {
-			if UI_USER_INTERFACE_IDIOM() == .pad {
-				popoverWidth = self.view.bounds.width * 0.6
-			} else {
-				popoverWidth = self.view.bounds.width
-			}
-		}
-		
-		let popoverHeight = min(preferredContentSize.height + self.popoverView.arrowHeight, view.bounds.height - popoverY - 40)
-		
-		return CGRect(
-			x: (self.view.bounds.width - popoverWidth) / 2,
-			y: popoverY,
-			width: popoverWidth,
-			height: popoverHeight
-		)
-	}
+        var popoverWidth = preferredContentSize.width
+        if popoverWidth == UIViewNoIntrinsicMetric {
+            if UI_USER_INTERFACE_IDIOM() == .pad {
+                popoverWidth = self.view.bounds.width * 0.6
+            } else {
+                popoverWidth = self.view.bounds.width
+            }
+        }
+        
+        let popoverHeight = min(preferredContentSize.height + self.popoverView.arrowHeight, view.bounds.height - popoverY - 40)
+        
+        return CGRect(
+            x: (self.view.bounds.width - popoverWidth) / 2,
+            y: popoverY,
+            width: popoverWidth,
+            height: popoverHeight
+        )
+    }
     
-    open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
-        if keyPath == "preferredContentSize" {
-            UIView.animate(withDuration: 0.2, animations: {
-                self.popoverView.frame = self.calculatePopoverViewFrame()
-            })
-        } else {
-            super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
-        }
+    // MARK: - Animation
+    
+    private func animatePopoverViewAfterChange() {
+        UIView.animate(withDuration: 0.2, animations: {
+            self.popoverView.frame = self.calculatePopoverViewFrame()
+        })
     }
+    
 }

    
    open class func dismissPopoverViewController() {
        let window = UIApplication.shared.keyWindow!

        for vc in window.rootViewController!.childViewControllers {
            if vc is DKPopoverViewController {
                (vc as! DKPopoverViewController).dismiss()

            arrowPath.addLine(to: CGPoint(x: arrowWidth, y: arrowHeight))
            arrowPath.addLine(to: CGPoint(x: 0, y: arrowHeight))
            arrowPath.closeSubpath()
            
            context?.addPath(arrowPath)
            
            context?.setFillColor(UIColor.white.cgColor)
            context?.drawPath(using: CGPathDrawingMode.fill)
            
            let arrowImage = UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()
            
