touch event not working in WkWebView
want to handle touch event in wkwebview, tried overriding touchesBegan and adding UITapGestureListener, still couldn't receive touch event call back.
iOS 10.1.1
Apple Event: May 7th at 7 am PT
want to handle touch event in wkwebview, tried overriding touchesBegan and adding UITapGestureListener, still couldn't receive touch event call back.
iOS 10.1.1
I had this question too, but couldn't find a straightforward answer as to why overriding touchesBegan and UIGestureListeners doesn't work on wkwebviews (If anyone knows why, please let me know).
I did some research and came up with 2 workarounds.
First workaround: look at this, this may help you.
http://stackoverflow.com/a/36287135
Personally, I don't like this method because it seems like a lot of work.
Second workaround:
Do some javascript injection. This worked for me.
Go here and scroll down a little.
I injected a modified version of jprochazka's code into my wkwebview.
https://www.youtube.com/watch?v=53Q7mhkES7c
I watched this video and learned how to listen for JavaScript events (like a scroll or a click on the webpage).
So I modified the JavaScript to trigger one of my Swift functions.
Ta da! The workaround is complete.
Hope this helps!
touch event not working in WkWebView