Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 932
Hassan Taleb Avatar asked Dec 10 '22 20:12

Hassan Taleb


1 Answers

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)
like image 78
Clement Prem Avatar answered Dec 28 '22 22:12

Clement Prem