 
         if collapsed { return }
         
-        guard let viewController = getPopoverViewController() else { return }
-        
+        guard let viewController = makePopoverViewController() else { return }
+
         viewController.modalPresentationStyle = .popover
         viewController.preferredContentSize = CGSize(width: 225, height: 250) // TODO: Calculate the preferred size from the actual content.
         let presentationController = viewController.popoverPresentationController!
         presentationController.delegate = self
         if let barButton = outerButton { presentationController.barButtonItem = barButton } else { presentationController.sourceView = self.imageView }
         self.viewController?.present(viewController, animated: true, completion: nil)
-    }
-
-    fileprivate func getPopoverViewController() -> UIViewController? {
+
+        popoverViewController = viewController
+    }
+
+    fileprivate func makePopoverViewController() -> UIViewController? {
         return nil
     }
 

        addTarget(self, action: #selector(toggle), for: .touchUpInside)
        
        sizeToFit()
    }
    
    public override func layoutSubviews() {

    }
    
    public func popoverPresentationControllerShouldDismissPopover(_ popoverPresentationController: UIPopoverPresentationController) -> Bool {
        popoverViewController = nil
        collapse()
        return true
    }
