Reputation: 21
Lately I have been trying to get Peek And Pop to work with my WKWebView. The use case I use it for is a RichText comment section in my App. But because there is already done plenty of customization done to the WebView I setup a minimal reproducible example.
So far I found out the following:
webView(_ webView: WKWebView, shouldPreviewElement...
should return true if you want to show a Peek and Pop. webView(_ webView: WKWebView, previewingViewControllerForElement...
should return the view controller to display for pop and peek.webView(_ webView: WKWebView, commitPreviewingViewController...
once the peek and pop is completed you should push the view to a navigation controller or present it modally here. The effect I am trying to achieve is displayed here.
Problem: What currently goes wrong is that I do return true from shouldPreviewElement, but then the second method, previewViewControllerForElement is never invoked as expected. I have also looked at other Pop and Peek implementations (outside of WKWebView and they work similarly and do not have this problem).
Upvotes: 2
Views: 537