How can I disable the magnifying glass that appears when you hold the touch on a UIWebView? I don't want to to disable user interaction but I don't want the webview to show that zoom glass. Any Ideas?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Do all browsers on iOS use WKWebview or UIWebVIew?
- Can not export audiofiles via “open in:” from Voic
Because the accepted solution did not work for me, I had to look for other options and I found one.
Note that I don't know if Apple approves this technique. Use it at your own fear and risk.
(Ours wasn't rejected; I don't think Apple cares that much about you messing with
UIWebView
internals, but be warned.)What I did was recursively walk down
UIWebView
subviews and enumerate theirgestureRecognizers
. Whenever I encounter aUILongPressGestureRecognizer
, I set itsenabled
toNO
.This gets rid of the magnifying glass altogether and obviously disables any default long-press functionality.
It seems like iOS re-enables (or re-creates) these gesture recognizers whenever user begins to edit text.
Well, I don't mind using magnifying glass in text fields so I don't disable them immediately.
Instead, I wait for
blur
event on my text elements, and when it occurs, I walk the subview tree again.Simple as that, and it works.
I have found that
-webkit-user-select: none;
alone doesn't do the trick. Instead I have found a quite undocumented property -webkit-touch-calloutWhat I usually do with Phonegap apps is this:
Somewhere it was mentioned that
-webkit-user-callout
is a legacy version of-webkit-touch-callback
, I have put this in just in case.No, the loupe is inextricably linked to selection. To disable it, you will have to disable selection entirely (you can use
-webkit-user-select: none
to do that).Because I don't know how to use
-webkit-user-select: none
I looked for other ways. And I stumble into this Customize the contextual menu of UIWebView then I combined it with-webkit-user-select: none
.For our Cordova & Swift project I did:
Note that this is my
CDVPlugin
class (or rather my custom version of it).Make sure your config.xml file has:
This will ensure the
init()
method is called.