Search code examples
cssxcodeswiftios9

How we can disable the magnification glass in uiwebview in ios 9 - Swift


How we can disable the magnification glass in uiwebview in ios 9 ?

I use this code below to disable the selection/copy.. in uiwebview:

* {
    -webkit-touch-callout: none;
     -webkit-user-select: none; /* Disable selection/copy in UIWebView */
}

it works, but the problem is the new magnification glass in ios 9, so is there any solution to disable it?
Note: I don't use Cordova


Solution

  • I just tried the following hack & it worked for me. This will override the long press in the webView.

    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:nil action:NULL];
    longPress.minimumPressDuration = 0.2;
    [webView addGestureRecognizer:longPress];
    

    Swift

     let longPress:UILongPressGestureRecognizer = UILongPressGestureRecognizer(target: nil, action: nil)
        longPress.minimumPressDuration = 0.2
        webView.addGestureRecognizer(longPress)