Swift - TipUIPopoverViewController to stay visible even on scroll

23 Views Asked by At

I'm playing and trying new things with the new tooltip from TipKit, but it seems that natively the tool is dismiss on scroll or outside tap on the screen. I was wondering if anyone succeed of making it stick until the main view is dismissed or on button action tap. I investigated the UIPopoverViewControllerDelegate but did not successfully made it work. I implemented it in my MainViewController and set my tooltip class popover delegate in it too.

class Tooltip {
    var tipPopoverController: TipUIPopoverViewController?

func displayToolTip(_ config: ToolTipCreatorConfig) {
    let popoverController = TipUIPopoverViewController(
        config.toolTip,
        sourceItem: config.sourceItem) { [weak self] _ in
            config.actionHandler()
        }
    popoverController.viewStyle = GenericTipViewStyle()
    popoverController.view.backgroundColor = Asset.Colors.bookmarkToolTipBackground.color
    // Set the passthroughViews property with an array of views that should receive touches
    popoverController.popoverPresentationController?.passthroughViews = config.enabledViewsToBeTouched ?? []

    self.mainViewController.present(popoverController, animated: true)
     }
}

class MainViewController: UIViewController {
    tooltip.displayPopOver(parentVC: self, config: config)  
    tooltip.tipPopoverController?.popoverPresentationController?.delegate = self
}

extension MainViewController: UIPopoverPresentationControllerDelegate {
                override func presentationControllerShouldDismiss(_ presentationController: UIPresentationController) -> Bool {
                    return false
                }
    }
0

There are 0 best solutions below