How to disable long touch in UIWebView?

烂漫一生 提交于 2019-11-27 12:12:42

问题


I want to disable long-touch from the application. I have no control on the HTML that I am loading on my WebView.


回答1:


In webViewDidFinishLoad delegate I run a javascript on the loaded html page that disable the long touch.

[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none'; document.body.style.KhtmlUserSelect='none'"];



回答2:


You could try to override the following methods from the view controller :

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

this way you can replace the usual touches management with your own implementation.




回答3:


Open your view in Interface Builder, click on the web view and then un-check the "User Interaction Enabled" checkbox in the attributes inspector.

If you want to do it in code, set the web view's userInteractionEnabled property to NO.



来源:https://stackoverflow.com/questions/4314193/how-to-disable-long-touch-in-uiwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!