Skip to content

Instantly share code, notes, and snippets.

@usagimaru
Created January 14, 2015 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usagimaru/da9b3c4d09a08396e705 to your computer and use it in GitHub Desktop.
Save usagimaru/da9b3c4d09a08396e705 to your computer and use it in GitHub Desktop.
Disabling callout and user selection on UIWebView

矩形選択を無効化する方法。コピー等のコンテクストメニューも出なくなる。

CSS

CSSに -webkit-touch-callout -webkit-user-select をぶち込んでおくだけ。

<style type="text/css">
<!--
* {
	-webkit-user-select: none;
	-webkit-touch-callout: none;
}
-->
</style>

Objective-C+JavaScript

-stringByEvaluatingJavaScriptFromString: メソッドによる制御。

[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment